wlbk.net
当前位置:首页 >> 用jAvA定义一个一维整型数组ArrAy={1,2,3,4,5,6,7,8,9,10},输出该数组元... >>

用jAvA定义一个一维整型数组ArrAy={1,2,3,4,5,6,7,8,9,10},输出该数组元...

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 ; for(int i = 0 ; i < score.length ; i++){ if(max <

可以这样,随机选取一个数组的下标,让该下标所在的值和第一个元素或者最后一个元素交换.重复执行直到所有的元素都交换过

int array[]={1,2,3,4,5,6,7,8,9,0}; 这样才行 或者 int array[] = new int[10]; 这样 不能像c语言那样定义 java定义数组 其实应该这么写 int [] array = {1,2,3,4,5,6,7,8,9,0};

int arr[] = {1,5,6,3,2,4,7,8,9,10}; int sum = 0; for (int i=3;i<arr.length;i++){ sum +=i; }

#include <stdio.h> int main() { int a[]= {1,2,3,4,5,6,7,8,9,10}, *p, i; p = a; for(i=0; i<10; i++) { printf("%d ", *p); p ++; } return 0; }

int[] num={1, 2, 3, 4, 5, 6, 7, 8, 9, 10};Console.WriteLine("第二个值:{0}",num[1]);

#include int main() { int a[]= {1,2,3,4,5,6,7,8,9,10}, *p, i; p = a; for(i=0; i printf("%d ", *p); p ++; } return 0; }

int sum=0;int[] array={1,2,3,4,5,6,7,8,9,10};for(int i=0;i 评论0 0 0

public static void main(String[] args) { String[] a = {"1","2","3","4","5","6","7","8","9","10","j","q","k"}; String[] b = new String[4]; int n = a.length; for(int i = 0; i < b.length; i++) { int r = (int)(Math.random()*n); b[i] = a[r]; a[r] = a[n - 1]; n--; System.out.print(b[i]+" "); } }//你也可以自己改成用户输入.

#include<stdio.h>void main(){int a[10]={1,2,3,4,5,6,7,8,9,10},sum= 0,i,j,temp;for(i=0;i<10;i++){for(j=0;j<10-i;j++){if(a[j]<a[j+1]){temp=a[j];a[j]=a[j+1];a[j+1]=temp;}}}printf("这个数来组逆序输自出是:百");for(i=0;i<10;i++){sum+=a[i];if(i==9){printf("%d",a[i]);}else{printf("%d,",a[i]);}}printf("这个数组的度和是:%d",sum);}

相关文档
sichuansong.com | eonnetwork.net | lyxs.net | bestwu.net | dkxk.net | 网站首页 | 网站地图
All rights reserved Powered by www.wlbk.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com