4.9上机作业-
package fff pubilc class fff{ pubilc static void main(String[] args){ int [] array={10,20,30,40,50}; for (int i:arr){ System.out.println(i); } }
public class fff{ pubilc static void main(String[] args){ int arss[]=new int [10,20,30,40,50]; Scanner sc=new Scanner(System.in); for(int i=0;i<ass.length;i++){ System.out.println("10,20,30,40,50"); ass[i]=sc.nextint(); } System.out.println("ok"); for(int i:ass){ System.out.println(i); } }
public class fff{ pubilc static void main(String[] args){ int[]arr={23,45,33,22,56}; int sum=0; for (int x=0;x<arr.length;x++){ sum+=x; } int sum=0; for(double y=0;y<arr.length;x++/5){ double y=sum/5; } System.out.println("i","y"); } }
public class fff{ pubilc static void main(String[] args){ int a[]={18,25,7,36,13,2,89,63}; int max=a[0]; for(int i=0;i<a.length-1;i++){ if(max<a[i]){ max=a[i]; index=i+1; } System.out.println("max","index"); } }
public class fff{ pubilc static void main(String[] args){ int[] a = { 12, 2, 45, 23, 9, 88, 33, 23, 22, 5, 4, 4, 5, 1, 9, 7, 2,7,8,0}; for (int j = 0; j < source.length - i; j++) { if (source[j] < source[j + 1]) { int temp = source[j]; source[j] = source[j + 1]; source[j + 1] = temp; printArray(source, i); } return source; } public static void printArray(int[] a,int idx) { for (int i = 0; i < a.length; i++) { System.out.print(a[i] + (i != a.length-1?",":"")); } System.out.println("--idx:" + idx); } }