第1题
第2题
第3题
例如,一维数组中的数据是:2 2 2 3 4 4 5 6 6 6 6 7 7 8 9 9 10 10 10。
删除后,数组中的内容应该是:2 3 4 5 6 7 8 9 10。
注意:部分源程序在文件PROGl.C中。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
第6题
第7题
第8题
用指针法求出数组元素中最大者和最小者。 int max,min; void max_min_value(array,n) int array[],n; {【 】; max=min=*array; for(【 】;p<array+n;p++) if(*p>max) max=*p; else if(*p<min)min=*p; } main() { int i,number[20],*p; p=number; printf("输入20个数据:\n"); for(i=0;i<20;i++,p++) scanf("%d",p); 【 】; max_min_value(p,10); printf("max=%-10dmin=%d\n",max,rain); }
第9题
以下程序是从终端读入数据到数组中,统计其中正数的个数,并计算它们的和。请填 main() { int i,a[20],sum,count; sum=count=【 】 ; for(i=0;i<20;i++)scanf("%d("%d",【 】 ); for(i=0;i<20;i++) { if(a[i]>0) {count++; sum+=【 】; } } printf("sum=%d,count=%d\n",sum,count); }
第10题