b=["3","2","1","6","5","2","1"]
a=int(b[0])
for i in range(6):
if a>int(b[i+1]):
a=a
else:
a=int(b[i+1])
print "第",i,"轮循环的a值为:",a #验证每次执行循环的正确性
print "列表最大值为:",a
----------------------------------------------------------------------------------------------------------
java:
public class HelloWorld {
public static void main(String []args) {
int[] array1=new int[]{2,1,4,3}; //声明数组并赋值
int num=array1[0];
for(int i=0;i<array1.length-1;i++){
if(num>array1[i+1]){
num=num;
}else{
num=array1[i+1];
}
System.out.println(array1[i]);
}
System.out.println("数值最大值为:"+num);
}
}
红尘往事,一切随风!