问答题
【参考答案】
int fun(int *s,int t,int *k){ int i; *k=0; /*k所指的数是数......
(↓↓↓ 点击下方‘点击查看答案’看完整答案、解析 ↓↓↓)
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
问答题
改错题下列给定程序中,函数fun()的功能是:从n个学生的成绩中统计出高于平均分的学生人数,人数由函数值返回,平均分存放在形参aver所指的存储单元中。例如输入8名学生的成绩:85 65.5 69 95.5 87 55 62.5 75则高于平均分的学生人数为4(平均分为74.312500)。请改正程序中的错误,使它能得到正确结果。注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。试题程序:#include #include #define N 20int fun(float *s, int n,float *aver){ **********************found*********************** int ave ,t=0; int count=0,k,i; for(k=0;k<n;k++) t+=s[k]; ave=t n; for(i=0;i<n;i++) **********************found*********************** if(s[i]<ave) count++; **********************found*********************** aver=ave; return count;}main(){ float s[30],aver; int m,i; clrscr(); printf( nPlease enter m: ); scanf( %d ,&m); printf( nPlease enter %d mark : n ,m); for(i=0;i<m;i++) scanf( %f ,s+i); printf( nThe number of students :%d n ,fun(s,m,&aver)); printf( Ave=%f n ,aver);}
点击查看答案&解析
多项选择题
填空题请补充main函数,该函数的功能是:从键盘输入一个字符串并保存在字符str1中,把字符串str1中下标为偶数的字符保存在字符串str2中并输出。例如,当str1=“cdefghij”,则str2=“cegi”。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:#include#include#define LEN 80main(){ char str1[LEN],str2[LEN]; char *p1=str1,*p2=str2; int i=0,j=0; clrscr(); printf( Enter the string: n ); scanf(【1】); printf( ***the origial string*** n ); while(*(p1+j)) { printf( 【2】 ,*(p1+j)); j++; } for(i=0;i<j;i+=2) *p2++=*(str1+i); *p2=’’ 0’’; printf( nThe new string is:%s n ,【3】);}
填空题请补充main函数,该函数的功能是:从键盘输入一个字符串并保存在字符str1中,把字符串str1中下标为偶数的字符保存在字符串str2中并输出。例如,当str1=“cdefghij”,则str2=“cegi”。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:#include
#include
#define LEN 80main(){ char str1[LEN],str2[LEN]; char *p1=str1,*p2=str2; int i=0,j=0; clrscr(); printf("Enter the string:\n"); scanf(【1】); printf("***the origial string***\n"); while(*(p1+j)) { printf("【2】",*(p1+j)); j++; } for(i=0;i
点击查看答案&解析
相关试题
改错题下列给定程序中,函数fun()的功能...
填空题请补充main函数,该函数的功能是:从...