ftsg.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[...

#include void main(){ int a[5]={3,6,-1,7,0};//定义数组 printf("%d %d %d %d %d \n",a[0],a[4],a[2],a[0]+a[1]+a[4],a[1]-a[3]);}//输出数组

static void Main(string[] args) { int[] nums = new int[] { 5, 7, 1, 3, 9, 13, 11, 15, 19, 17 }; nums = Sort(nums, 0, nums.Length - 1); for (int t = nums.Length - 1; t >= 0; t--) { Console.WriteLine(nums[t]); } } private static ...

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

public static void test1(){ Integer[] s = {1,3,5,7,9,11,13,15,17,19}; Comparator cmp = new MyComparator(); Arrays.sort(s, cmp); for(Integer i:s){ System.out.println(i); } } static class MyComparator implements Comparator { @Ove...

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

#include void main() { int n[10]; int i; for (i=0; i=0; i--) printf("%d\n", n[i]); }

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 "stdio.h"int main(int argv,char *argc[]){int a[5]={3,6,-1,7,0};printf("%d %d %d %d %d\n",a[0],a[4],a[2],a[0]+a[1]+a[4],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

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