标签:ati i++ 排序 blog [] code sys 取数 span
public static void main(String[] args) { int[] va = {45,7,67,87,98,0,45,78,100}; int tmp = va[0]; for(int i=1;i<va.length;i++){ if(tmp<va[i]){ tmp = va[i]; i++; } }
System.out.println(tmp); //最大值 }
public static void main(String[] args) { int[] va = {45,7,67,87,98,0,45,78,100}; int tmp=va[0]; for(int i=0;i<va.length-1;i++){ for(int y=i+1;y<va.length;y++){ if(va[i]>va[y]){ tmp = va[i]; va[i] = va[y]; va[y] = tmp; } } } for(int i:va){ System.out.print(i); System.out.print(" "); } }
public static void main(String[] args) { int[] va = {45,7,67,87,98,0,45,78,100}; int tmp=va[0]; for(int i=0;i<va.length-1;i++){ for(int y=0;y<va.length-1-i;y++){ if(va[y] > va[y+1]){ tmp = va[y]; va[y] = va[y+1]; va[y+1] = tmp; } } } for(int i:va){ System.out.print(i); System.out.print(" "); } }
标签:ati i++ 排序 blog [] code sys 取数 span
原文地址:http://www.cnblogs.com/dsitn/p/7412890.html