Part1
#includeconst int N=5;int main(){ int a[N] = { 1, 2, 3, 4, 5}; int i; for(i=0; i
#includeconst int N=5;int main(){ char a[5] = { 'h','e','l','l','o'}; int i; for(i=0; i
#includeconst int N=5;int main(){ double a[5] = { 1.0, 2.0, 3.0, 4.0, 5.0}; int i; for(i=0; i
Part2
#includeint main(){ int a[5]; a[0] = 1; a[1] = 9; a[2] = 8; a[3] = 6; a[4] = 0; printf("a[0] = %d\n", a[0]); printf("a[1] = %d\n", a[1]); printf("a[2] = %d\n", a[2]); printf("a[3] = %d\n", a[3]); printf("a[4] = %d\n", a[4]); return 0;}
Part3
#includeconst int N=5;int main(){ int score[N] = { 99, 82, 88, 97, 85}; int i; for(i=0; i
#includeconst int N=5;void print(int x);int main(){ int score[N] = { 99, 82, 88, 97, 85}; int i; for(i=0; i
#includeconst int N=5;void init(int a[],int n, int value);int main(){ int b[N],i; init(b,N,-1); for(i=0;i
Part4
#includeconst int N=5;void bubbleSort( int [], int); int main() { int i,a[N]; printf("请输入%d个整型数据: \n", N); for(i=0; i x[j+1] ) { t = x[j]; x[j] = x[j+1]; x[j+1] = t; } } }}
Part5
#includeint findMax(int a[], int n); // 函数声明const int N=5;int main() { int a[N]; int max, i; printf("输入%d个整数: \n", N); for(i=0;i<5;i++) scanf("%d",&a[i]); max=findMax(a,N); printf("数组a中最大元素值为: %d\n\n", max); return 0;} int findMax(int a[],int n){ int i,max; max=a[0]; for(i=0;i<5;i++){ if(a[i]>max) max=a[i]; } return max; }
#includeconst int N=4;void output(char x[], int n);void bubbleSort(char x[],int n); int main() { char string[N] = { '2','0','1','9'}; int i; printf("排序前: \n"); output(string, N); bubbleSort(string,N); printf("\n排序后: \n"); output(string, N); printf("\n"); return 0; } void output(char x[], int n) { int i; for(i=0; i