问答题
【参考答案】
void fun(int m, int k, int xx[]){ int i,j,n; for(i=m+A,n=0......
(↓↓↓ 点击下方‘点击查看答案’看完整答案、解析 ↓↓↓)
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
问答题
改错题下列给定程序中,函数fun()的功能是计算并输出high以内的素数之和。high由主函数传给fun()函数。若high的值为100,则函数的值为1060。请改正程序中的错误,使它能得到正确结果。注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。试题程序:#include #include #include int fun(int high){ int sum=0,n=0, j, yes;while(high>=2){yes = 1;for(j=2; j<=high 2; j++) **********************found*********************** ifhigh%j==0 {yes=0; break;} **********************found*********************** if(yes==0) {sum+=high;n++;}high--;}return sum;}main(){clrscr();printf( %d n ,fun(100));}
点击查看答案&解析
多项选择题
填空题请补充main函数,该函数的功能是:从一个字符串中截取前面若干个给定长度的子字符串。其中,str1指向原字符串,截取后的字符存放在str2所指的字符数组中,n中存放需截取的字符个数。例如:当str1=“cdefghij”,然后输入4,则str2=“cdef”。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:#include #include#define LEN 80main(){ char str1[LEN],str2[LEN]; int n,i; clrscr(); printf( Enter the string: n ); gets(str1); printf( Enter the position of the string deleted: ); scanf(【1】); for(i=0;i<n;i++) 【2】 str2[i]=’’ 0’’; printf( The new string is:%s n ,【3】);}
填空题请补充main函数,该函数的功能是:从一个字符串中截取前面若干个给定长度的子字符串。其中,str1指向原字符串,截取后的字符存放在str2所指的字符数组中,n中存放需截取的字符个数。例如:当str1=“cdefghij”,然后输入4,则str2=“cdef”。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:#include
#include
#define LEN 80main(){ char str1[LEN],str2[LEN]; int n,i; clrscr(); printf("Enter the string:\n"); gets(str1); printf("Enter the position of the string deleted:"); scanf(【1】); for(i=0;i
点击查看答案&解析
相关试题
填空题请补充main函数,该函数的功能是:从...
改错题下列给定程序中,函数fun()的功能...