mdsk.net
当前位置:首页 >> 有一个整型数组,其中存放{1,2,3,4,5,6,7,... >>

有一个整型数组,其中存放{1,2,3,4,5,6,7,...

方法不少,最直接的一种:倒叙存放,然后打印输出: public class ReverseArray { public static void main(String[] args) { int arr[] = new int[] { 1,2,3,4,5,6,7,8,9 }; for(int i = 0; i < arr.length / 2; i++){ int temp = arr[i]; arr[...

int arry[]={2,1,4,3,7,9,6};Arrays.sort(arry);for(Integer a : arry) {System.out.println(a);}

public class Test{ public static void main(String args[]){ int score[] = null ; score = new int[10] ; for(int i = 0 ; i < score.length ; i++){ score[i] = i ; } int max , min , sum ; max = score[0] ; min = score[0] ; sum = 0 ; f...

#include void main(){ int i; int num[10]; num[0]=0; num[1]=1; num[2]=2; num[3]=3; num[4]=4; num[5]=5; num[6]=6; num[7]=7; num[8]=8; num[9]=9; printf("这个数组是:"); for(i=0;i

#includeint main(){int a[5]={3,6,-1,7,0};printf("%d ",a[0]);printf("%d ",a[4]);printf("%d ",a[2]);printf("%d ",a[0]+a[1]+a[4]);printf("%d\n",a[1]-a[3]);return(0);}

public class Test{ public static void main(String args[]) { int arr[] = {1,2,3,4,5,6,7,8,9,10}; int sum = 0; int avg=0 for (int i=0;i

public static void main(String[] args) { int [] num={2,4,8,10,12,14,16,18,20}; int size = num.length; double vag = 0.0; int sum = 0; for (int i = 0; i < size; i++) { sum += num[i]; vag = sum/size; } System.out.println("计算总和...

#include int main () { int a[10],d,f,t=0,temp; for(d=0;d9/2;f--) {temp=a[t]; a[t]=a[f]; a[f]=temp; t=t+1;} for(t=0;t

亲,你要的答案,不知道是不是你想要的 public class chLoc {public static void main(String[] args) {int [] array=new int[]{1,56,28,8,22};for(int i=0;i

#include int main() { int number,digit; number=123456; do { digit=number % 10; printf("%d",digit); number=number / 10; } while (number != 0); }

网站首页 | 网站地图
All rights reserved Powered by www.mdsk.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com