云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > C语言程序设计练习题(含程序及参考答案)

C语言程序设计练习题(含程序及参考答案)

  • 62 次阅读
  • 3 次下载
  • 2025/6/23 16:02:10

.

for ( k = 0; k < n; k++ ) if((k+1) ==0) printf(\ else printf( \ printf(\ }

28、请编写函数int fun(int m,int score[],int below[]),它的功能是:将低于平均分的人数作为函数值返回,并将低于平均分的成绩放在below数组中(m表示score的长度,score表示成绩)。例如,当score数组中的数据为:10、20、30、40、50、60、70、80、90时,函数返回4,below中的数据应为:10、20、30、40。 #include #include

int fun(int score[], int m, int below[]) {

for(i=0;i

total=total+score[i];

整理版

int total=0; int average=0; int *p_below=below; int i=0; int j=0;

.

}

}

average=total/m; for(i=0;i

if(score[i]

*p_below=NULL; return(j);

main( )

{ int i, n, below[9] ;

int score[9] = {10, 20, 30, 40, 50, 60, 70, 80, 90} ;

n = fun(score, 9, below) ;

printf( \ for (i = 0 ; i < n ; i++) printf(\ }

整理版

.

29、用插入排序法将n个字符进行排序(降序)。(提示:插入法排序的思路是:先对数组的头两个元素进行排序,然后根据前两个元素的情况插入第三个元素,再插入第四个元素…)。 #define N 80 #include \ #include \

void insert(char *aa) {

int i,j,n; char ch; n=strlen(aa);

for(i=1;i

{

ch=aa[i]; j=i-1;

while ((j>=0)&&(ch

j--; }

aa[j+1]=ch;

整理版

{

.

} }

void main()

{ char a[N]=\ int i;

printf(\ %s\\n\ insert(a);

printf(\ }

30、假定整数数组a中元素的值不重复。删除a中值为x的元素(x从键盘输入)。 #include #define N 20 fun(int *a,int n,int x) { int p=0,i; a[n]=x; while(x!=a[p]) p=p+1;

if(p==n)

return -1; else

整理版

  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

. for ( k = 0; k < n; k++ ) if((k+1) ==0) printf(\ else printf( \ printf(\ } 28、请编写函数int fun(int m,int score[],int below[]),它的功能是:将低于平均分的人数作为函数值返回,并将低于平均分的成绩放在below数组中(m表示score的长度,score表示成绩)。例如,当score数组中的数据为:10、20、30、40、50、60、70、80、90时,函数返回4,below中的数据应为:10、20、30、40。 #include #include int fun(int score[], int m, int below[]) {

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com