简答题从键盘任意输入一个整数,编程判断它的奇偶性。按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。 #include int main() { int a; printf("Input an integer number:"); scanf("%d", &a); if (________) printf("a is an even number\n"); else printf("a is an odd number\n"); return 0; } A、a%2 = 0 B、a%2 == 0 C、a/2 = 0 D、a%2 != 0简答题已知不等式:1! + 2! + … + m! #include int main() { unsigned long i, n, term = 1, sum = 0; printf("Please enter n:"); scanf("%lu", &n); for (___________) { term = term * i; sum = sum + term; if (sum >= n) ________; } printf("m return 0; } A、第7行: i=1; ;i++ 第11行: continue B、第7行: i=1;i++ 第11行: break C、第7行: i=1;i++ 第11行: continue D、第7行: i=1; ;i++ 第11行: break简答题我国古代的《张丘建算经》中有这样一道著名的百鸡问题:“鸡翁一,值钱五;鸡母一,值钱三;鸡雏三,值钱一。百钱买百鸡,问鸡翁、母、雏各几何?”其意为:公鸡每只5元,母鸡每只3元,小鸡3只1元。用100元买100只鸡,问公鸡、母鸡和小鸡各能买多少只? 代码如下,按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。 #include int main() { int x, y, z; for (x=0; x { for (y=0; _________; y++) { _______________; if (_______________) { printf("x=%d, y=%d, z=%d\n", x, y, z); } } } return 0; } A、第7行: y 第9行: z + y + x = 100 第10行: 5*x + 3*y + z/3.0 = 100 B、第7行: y 第9行: z = 100 – x - y 第10行: 5*x + 3*y + z/3.0 == 100 C、第7行: y 第9行: z = 100 – x - y 第10行: 5x + 3y + z/3.0 == 100 D、第7行: y 第9行: z+x = 100 - y 第10行: 5*x + 3*y + z/3.0 = 100简答题下面程序的功能是计算 a + aa + aaa + … + aa…a(n个a)的值,n和a的值由键盘输入。按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。 #include int main() { long ________, sum = 0; int a , i, n; printf("Input a,n:"); scanf("%d,%d", &a, &n); for (i=1; i { term = ___________; sum = sum + term; } printf("sum = %ld\n", sum); return 0; } A、第4行: term = 0 第11行: term * 10 + a B、第4行: term 第11行: 10term + a C、第4行: term = 1 第11行: term *10 + a D、第4行: term 第11行: a * 10 + term简答题爱因斯坦数学题。爱因斯坦曾出过这样一道数学题:有一条长阶梯,若每步跨2阶,最后剩下1阶;若每步跨3阶,最后剩下2阶;若每步跨5阶,最后剩下4阶;若每步跨6阶,最后剩下5阶;只有每步跨7阶,最后才正好1阶不剩。请问,这条阶梯共有多少阶? 代码如下,按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。 #include int main() { int x = 1, find = 0; while (__________) { if (______________________) { printf("x = %d\n", x); find = 1; } x++; } return 0; } A、第5行: !find 第7行: x%2==1 && x%3==2 && x%5==4 && x%6==5 && x%7==0 B、第5行: find==1 第7行: x%2==1 && x%3==2 && x%5==4 && x%6==5 && x%7==0 C、第5行: find!=1 第7行: x/2==1 && x/3==2 && x/5==4 && x/6==5 && x/7==0 D、第5行: find!=0 第7行: x%2==1 && x%3==2 && x%5==4 && x%6==5 && x%7==0简答题从键盘输入一个英文字母,如果它是大写英文字母,则将其转换为小写英文字母,如果它是小写英文字母,则将其转换为大写英文字母,然后将转换后的英文字母及其ASCII码值显示到屏幕上,如果不是英文字母,则不转换直接将它及其ASCII码值输出到屏幕上。按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。 #include int main() { char ch; printf("Press a key and then press Enter:"); ch = getchar(); if (____________) ch = ch + 32; else if (________________) ch = ch - 32; printf("%c, %d\n", ch, ch); return 0; } A、第8行: ch >= 'A' && ch 第12行: ch >= 'a' && ch B、第8行: ch >= A && ch 第12行: ch >= a && ch C、第8行: ch ≥ 'A' && ch ≤ 'Z' 第12行: ch ≥'a' && ch ≤ 'z' D、第8行: ch ≥ A && ch ≤ Z 第12行: ch ≥ a && ch ≤ z简答题输入某班学生某门课的成绩(最多不超过40人,具体人数由用户键盘输入),用函数编程统计不及格人数。按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。 #include #define N 40 intGetFailNum(int score[], int n); int main() { int i, n, fail, score[N]; printf("How many students?"); scanf("%d", &n); for (i=0; i { scanf("%d", &score[i]); } fail = GetFailNum(score, n); printf("Fail students = %d\n", fail); return 0; } /* 函数功能:统计不及格人数 */ int GetFailNum(_________, int n) { int i, count = 0; for (i=0; i { if (____________) count++; } return ________; } A、第19行: int score[] 第24行: score[i] 第26行: i B、第19行: int score 第24行: score[i] 第26行: count C、第19行: int score[] 第24行: score[i] 第26行: count D、第19行: int score 第24行: score[i] >= 60 第26行: score[i]简答题在海军节开幕式上,有A、B、C三艘军舰要同时开始鸣放礼炮各21响。已知A舰每隔5秒放1次,B舰每隔6秒放1次,C舰每隔7秒放1次。假设各炮手对时间的掌握非常准确,请编程计算观众总共可以听到几次礼炮声。按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。 #include int main() { int n = 0, t; for (t=0; t { if (____________________) /* 控制A舰每隔5秒放1次 */ { n++; _________; /* 继续下一次循环 */ } if (___________________) /* 控制B舰每隔6秒放1次 */ { n++; ___________; /* 继续下一次循环 */ } if (___________) /* 控制C舰每隔7秒放1次 */ { n++; } } printf("n = %d\n", n); } A、第7行: t%5 = 0 && t 第10行: break 第12行: t%6 = 0 && t 第15行: break 第17行: t%7 == 0 B、第7行: t%5 == 0 || t 第10行: continue 第12行: t%6 == 0 || t 第15行: continue 第17行: t%7 == 0 || t C、第7行: t%5 == 0 && t 第10行: break 第12行: t%6 == 0 && t 第15行: break 第17行: t%7 = 0 D、第7行: t%5 == 0 && t 第10行: continue 第12行: t%6 == 0 && t 第15行: continue 第17行: t%7 == 0简答题完全数,又称完美数或完数(Perfect Number),它是指这样的一些特殊的自然数,它所有的真因子(即除了自身以外的约数)的和,恰好等于它本身。例如,6就是一个完全数,是因为6 = 1 + 2 + 3。请编写一个判断完全数的函数IsPerfect(),然后判断从键盘输入的整数是否是完全数。注意:1没有真因子,所以不是完全数。 代码如下,按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。 #include #include int IsPerfect(int x); int main() { int m; printf("Input m:"); scanf("%d", &m); if (_________________) /* 完全数判定 */ printf("%d is a perfect number\n", m); else printf("%d is not a perfect number\n", m); return 0; } /* 函数功能:判断完全数,若函数返回0,则代表不是完全数,若返回1,则代表是完全数 */ int IsPerfect(int x) { int i; int total = 0; /* 1没有真因子,不是完全数 */ for (__________________) { if (___________) total = total + i; } return total==x ? 1 : 0; } A、第10行: m 第24行: i=1; i 第26行: x % i != 0 B、第10行: IsPerfect(m) 第24行: i=1; i 第26行: x % i == 0 C、第10行: IsPerfect(m)!=1 第24行: i=0; i 第26行: x / i == 0 D、第10行: IsPerfect(m)==0 第24行: i=0; i 第26行: x % i = 0简答题对指定的正实数n,试求满足下面平方根不等式的最小整数m,并输出不等式左边的值。按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。 #include #include int main() { int i, m; double s, n; printf("Input n:\n"); scanf("%lf", &n); for (m = 1; m { s = 0; for (i = m; ________; i++) { s = _________; } if (s > n) { _______; } } printf("Result:m>=%d\n", m); printf("s=%.2lf\n", s); return 0; } A、第12行: i 第14行: s + sqrt(m) 第19行: continue B、第12行: i 第14行: s + sqrt(i) 第19行: continue C、第12行: i 第14行: s + sqrt(m) 第19行: break D、第12行: i 第14行: s + sqrt(i) 第19行: break简答题在字符串中删除与某字符相同的字符,要求用字符数组作函数参数。程序运行结果如下: Input a string: hello, my friend!↙ Input a character: !↙ Results:hello, my friend 在空白处填写适当的表达式或语句,使程序完整并符合题目要求。 #include void Squeeze(char s[], char c); int main() { char str[20], ch; printf("Input a string:\n"); gets(str); printf("Input a character:\n"); ch = getchar(); Squeeze(str, ch); printf("Results:%s\n", str); return 0; } void Squeeze(char s[], char c) { int i, j; for (i=j=0; ________; i++) { if (_________) { ___________; j++; } } s[j] = '\0'; /* 在字符串s的末尾添加字符串结束标志 */ } A、第18行: s[i]=='\0' 第20行: s[i] = c 第22行: s[i] = s[j] B、第18行: s[i]= '\0' 第20行: s[i] == c 第22行: s[j] = s[i] C、第18行: s[i]!= '\n' 第20行: s[i] = c 第22行: s[i] = s[j] D、第18行: s[i]!='\0' 第20行: s[i] != c 第22行: s[j] = s[i]简答题有5个人围坐在一起,问第5个人多大年纪,他说比第4个人大2岁;问第4个人,他说比第3个人大2岁;问第3个人,他说比第2个人大2岁;问第2个人,他说比第1个人大2岁。第1个人说自己10岁,问第5个人多大年纪。用递归法编写程序,按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。递归公式为: #include unsigned int ComputeAge(unsigned int n); int main() { unsigned int n = 5; printf("The 5th person's age is %d\n", ComputeAge(n)); return 0; } // 函数功能:用递归算法计算第n个人的年龄 unsigned int ComputeAge(unsigned int n) { unsigned int age; if (________) { age = 10; } else { age = ______________; } return ______; } A、第13行: n = 1 第19行: ComputeAge(n) + 2 第21行: age B、第13行: n == 1 第19行: ComputeAge(n - 1) + 2 第21行: age C、第13行: n = 1 第19行: ComputeAge(n - 1) + 2 第21行: n D、第13行: n == 1 第19行: n - 1 + 2 第21行: n简答题下面程序的功能是输出一个正整数等差数列的前十项,该输出数列的前四项之和是26,该输出数列的前四项之积是880。代码如下,按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。 #include int main() { int a,d,i,s,f,x; for (a=1;a { for(d=1;d { s=0; f=1; x=a; for(i=1;i { s=s+x; f=f*x; x=x+d; } if(______________) { for(i=0;_________;i++) printf("%3d",_________); } } } return 0; } A、第19行: s=26 && f=880 第21行: i 第23行: i*d B、第19行: s==26 || f==880 第21行: i 第23行: a+i C、第19行: s==26 && f==880 第21行: i 第23行: a+i*d D、第19行: s=26 || f=880 第21行: i 第23行: d+i*a