python列表和字符串的三种逆序遍历方式 列表的逆序遍历 a = [1,3,6,8,9] print("通过下标逆序遍历1:") for i in a[::-1]: print(i, end=" ") print("\n通过下标逆序遍历2:") for i in range(len(a)-1,-1,-1): print(a[i], end=" ") print("\n通过reversed逆序遍历:") f…
▷//第一种求法,使用while结构 /** * @author 9527 * @since 19/6/20 */ public class Gaosi { public static void main(String[] args) { //设置一个数值为0的变量,这个变量用来储存1到100的累加之和 int sum = 0; //设置一个自增变量,从1开始 int i = 1; //当这个自增变量≤100的时候,进行累加 while(i<= 100){ //在储存数值的变量里面循环储存i的值…