1、C 世界 http:/ C 世界 http:/ C 语言上机操作题.第 1 套填空题请补充 FUN 函数, FUN 函数的功能是求 10 的阶乘。注意:部分源程序给出如下。请勿改动主函数 main 和其他函数中的任何内容,仅在 fun 函数的横线上填入所编写的若干表达式或语句。试题程序: #include long fun(int n)if (_1_)return (n*fun(_2_);return _3_;main()printf(“10!=%ldn“, fun(10);第 1 处填空:n1 或 1#include /*found*/IsPrime(int n);int i, m;m =
2、1;/*found*/for (i=2; i#include #include int fun(int score,int m, int below)main()int i,n,below9;int score9=10,20,30,40,50,60,70,80,90;FILE *out;n=fun(score,9,below);printf(“nBelow the average score are :“);out=fopen(“out.dat“, “w“);for(i=0;iint fun(int n);main()int i, n = 0;scanf(“%d“, for (i=0; i#i
3、nclude void fun(char *p, char *q, char *c)/*found*/int k = 1;/*found*/while (*p != *q)if (*p #include void fun(int *a,int *n) main() int aa1000,n,k;FILE *out;fun(aa,out=fopen(“out.dat“, “w“);for(k=0;k#include #include #define N 81void fun(char *s)int i, n = strlen(s)-1;char t;for (i=0; i#include voi
4、d fun(char *s)int i, j;- 5 -/*found*/for (i=0, j=0; si!=0; i+)if (sj=0 FILE *out;printf(“nPlease enter an integer number:n“); scanf(“%d“,fun(x,aa,for(i=0;idouble fun(int n)int i;double sum = 0.0;for (i=1; _1_; i+)if (i%3=0 _2_ i%7=0)sum += _3_/i;return sum;main()int n;double s;printf(“nInput n: “);s
5、canf(“%d“, s = fun(n);printf(“nns=%fn“, s);第 1 处填空:i=i第 2 处填空:|第 3 处填空:1.0 或(double)1改错题下列给定程序中,fun 函数的功能是:分别统计字符串中大写字母和小写字母的个数。例如,给字符串 s 输入:AaaaBBb123CCccccd,则应输出结果:upper=6,lower=8请改正程序中的错误,使程序能得出正确的结果。注意:不要改动 main 函数,不得增行或删行,也不得更改程序的结构!试题程序:#include #include /*found*/void fun(char *s, int a, int b
6、)- 7 -while (*s)/*found*/if (*s=A int bb26, k;FILE *out;printf(“nPlease enter a char string:“);scanf(“%s“,aa);fun(aa,bb);for(k=0;kdouble fun(double r)return 3.14159*_1_/2.0;- 9 -main()double x;printf(“Enter x: “);scanf(“%lf“, _2_);printf(“ s = %lfn “, fun(_3_);第 1 处填空:r*r第 2 处填空:an = x;while (x != a
7、p)p = p+1;if (p = n)return -1;else/*found*/for (i=p; in; i+)ai+1 = ai;return n-1;main()int wN = -3, 0, 1, 5, 7, 99, 10, 15, 30, 90, x, n, i;n = 10;printf(“The original data:n“);for (i=0; in; i+)printf(“%5d“, wi);printf(“nInput x (to delete):“);scanf(“%d“, printf(“Delete :%dn“, x);n = fun(w, n, x);if (n = -1)printf(“*Not be found!*nn“);elseprintf(“The data after delete :n“);for (i=0; in; i+)printf(“%5d“, wi);printf(“nn“);