简答题 | 以下程序输出的结果是 _________。 int ff(int n) { static int f=l; f=f*n; return f; } main() { int i; for(i=1;i<=5;i++) printf("%d\n",ff(i)); } |
查看答案 |
简答题 | 设有以下程序: main() { int n1,n2; scanf("%d",&n2); while(n2!=0) { n1=n2 ; n2=n2/10; printf("%d ",n1); } } 程序运行后,如果从键盘上输入1298;则输出结果为_________。 |
查看答案 |
简答题 | 下面程序的功能是:输出 100以内(不包含100)能被 3整除且个位数为 6的所有整数,请填空。 #Include main() { int i, j; for(i=1; ____________; i++) if (________________) printf("%d", j); } |
查看答案 |
简答题 | 编程实现求解下面的式子的结果 s=1*2+2*3+3*4+…+20*21 |
查看答案 |
简答题 | 编程实现求下面的式子的结果 | 查看答案 |
简答题 | 编程实现将文本文件file1.dat的内容读出来,显示到屏幕上。 | 查看答案 |
简答题 | 改正下列程序中不正确的语句。 main( ) { int a; scanf(“%d”, a); if (a = 1) printf(“One\n”) ; } |
查看答案 |
简答题 | 写出下列程序的运行结果。 fun(int a, int b) { if(a>b) return (a); Else return (b); } main() { int x=3,y=8,z=6,r; r=fun(fun(x,y),2*z); printf(“%d\n”,r); } |
查看答案 |
简答题 | 改正下列程序中不正确的语句。 main() { int n ; float s=1.0; for(n=10;n>1;n- -) s=s+1/n; printf(“%6.1f\n”,s); } |
查看答案 |
简答题 | 写出下列程序的运行结果。 main() { int n; For(n=3; n<=10; n++) { if(n%6= =0) break; Printf(“%d”,n); } } |
查看答案 |
简答题 | 写出下列程序的运行结果。 #include “stdio.h” Main() { int a[]={1,2,3,-4,5}; int m,n,*p; p=&a[0]; m=*(p+1); n=*(p+4); printf(“%d %d %d ”,*p,m,n); } |
查看答案 |
简答题 | 编程计算下列表达式:s=n!(n从键盘上输入) | 查看答案 |
简答题 | 输出1—100之间不能被12整除的数。 | 查看答案 |
简答题 | 从键盘上输出10个整数存入一维数组中,按由大到小的顺序输出。 | 查看答案 |
简答题 | 从键盘上输入9个数,按3行3列的格式输出。 | 查看答案 |
简答题 | 编程将文件read.txt中的字符读出显示到屏幕上。 | 查看答案 |
简答题 | float f=3.1415927; printf(“%f,%5.4f,%3.3f”,f,f,f); 则程序的输出结果是__________ 。 |
查看答案 |
简答题 | int x=6, y=7; printf(“%d,”,x++); printf(“%d\n”,++y); 程序的输出结果是__________ 。 |
查看答案 |
简答题 | a=3; a+=(a<1)?a:1; printf(“%d”,a); 结果是__________。 |
查看答案 |
简答题 | for (a=1,b=1;a<=100;a++) { if(b>=20) break; if(b%3==1) {b+=3; continue;} b-=5; } 程序的输出结果a的值为__________ 。 |
查看答案 |
简答题 | int y=1, x, *p, a[ ]={2,4,6,8,10}; p=&a[1]; for(x=0;x<3;x++) y + = * (p + x); printf("%d\n",y); 程序的输出结果y的值是__________ 。 |
查看答案 |
简答题 | 三个整数a、b、c,由键盘输入,输出其中最大的一个数。 | 查看答案 |
简答题 | 输出1900~2000年中所有的闰年。每输出3个年号换一行。(判断闰年的条件为下面二者之一:能被4整除,但不能被100整除。或者能被400整除。) | 查看答案 |
简答题 | 请编一个函数int fun(int a),它的功能是:判断a是否是素数,若a是素数,返回1;若不是素数,返回0。A的值由主函数从键盘读入。 | 查看答案 |
简答题 | 有N个学生,每个学生的信息包括学号、性别、姓名、四门课的成绩,从键盘上输入N个学生的信息,要求输出总平均成绩最高的学生信息,包括学号、性别、姓名和平均成绩。 | 查看答案 |
简答题 | int x=6, y=7; printf(“%d,”,x++); printf(“%d\n”,++y); 程序的输出结果是__________。 |
查看答案 |
简答题 | float f=3.1415927; printf(“%f,%5.4f,%3.3f”,f,f,f); 则程序的输出结果是__________。 |
查看答案 |
简答题 | a=3; a+=(a<1)?a:1; printf(“%d”,a); 结果是__________。 |
查看答案 |
简答题 | main( ) { int a[5]={2,4,6,8,10},*P,* *k; p=a; k=&p; printf("%d,",*(p++)); printf("%d\n",* *k); } 程序的输出结果是__________。 |
查看答案 |
简答题 | main() {int a,b; for (a=1,b=1;a<=100;a++) { if(b>=20) break; if(b%3==1) {b+=3; continue; } b-=5; } } 程序的输出结果a的值为__________。 |
查看答案 |
简答题 | 三个整数a、b、c,由键盘输入,输出其中最大的数。 | 查看答案 |
简答题 | 从键盘输入的10个整数中,找出第一个能被7整除的数。若找到,打印此数后退出循环;若未找到,打印“not exist”。 | 查看答案 |
简答题 | 有一个一维数组,内放10个学生成绩,写一个函数,求出平均分。 | 查看答案 |
简答题 | 有N个学生,每个学生的信息包括学号、性别、姓名、四门课的成绩,从键盘上输入N个学生的信息,要求输出总平均成绩最高的学生信息,包括学号、性别、姓名和平均成绩。 | 查看答案 |
简答题 | 请补充main()函数,该函数的功能是:输入两个正整数numl和num2,求这两个数的最大公约和最小公倍数。 例如,若输入的两个正整数为12,4,则它们的最大公约数为12,最小公倍数为4。 注意:部分源程序给出如下。 请勿改动main()函数和其他函数中的任何内容,仅在main()函数的横线上填人所编写的若干表达式或语句。 试题程序: #include #include void main() { int a,b,numl,num2,t; system("CLS"): printf("\nInput two numbers:\n"); scanf("%d,%d",&numl,&num2); if(numl<NUM2) { a=num2; b=num1: } else { a=num1; b=num2; } while(【1】) { t= 【2】 a=b; b=t: } printf(“greatest common divisor: %d\n",a); printf("least common multiple: %d\n", 【3】; } |
查看答案 |
简答题 | 下列给定程序中,函数proc()的功能是:根据输入的3个边长(整型值),判断能否构成三角形:若能构成等边三角形,则返回3;若是等腰三角形,则返回2;若能构成三角形则返回 1;若不能,则返回0。 例如,输入3个边长为3,4,5,实际输入时,数与数之间以Enter键分隔而不是逗号。请修改程序中的错误,使它能得出正确的结果。 注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include #include int proc(int a,int b,int c) { if(a+b>c&&b+c>a&&a+c>b) { if(a= =b&&b= =c) //****found**** return 1; else if(a= =b||b= =c||a= =c) return 2; //****found**** else return 3; } else return 0; } void main() { int a,b,C,shape; printf("\nlnput a,b,C:"); scanf("%d%d%d",&a,&b,&c); printf("\na=%d,b=%d,c=%d\n",a,b,c); shape=proc(a,b,c); printf("\n\nThe shape:%d\n",shape); } |
查看答案 |
简答题 | 学生的记录由学号和成绩组成,M名学生的数据已在主函数中放入结构体数组stu中,请编写函数proc(),其功能是:按分数的高低排列学生的记录,高分在前。 注意:部分源程序给出如下。 请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的花括号中填入所编写的若干语句。 试题程序: #include #define M l6 typedef struct { char num[l0]; int S; } STREC: void proc(STREC a[]) { int i,j; STREC t; for(i=1;i 排序*/ for(j=0;j<M-1;J++)&NBSP;。 if(a[j].s 的记录,高分在前*/ {t=a[j];a[j]=a[j+1];a[j+1]=t;) } void main() { STREC stu[M]={{"GA005",85),{"GA003",76}, {"GA002",69},{"GA004",85),{"GA001",91), {"GA007",72),{"GA008",64),{"GA006",87), {"GA015",85),{"GA013",91),{"GA012",64), {¨GA014",91),{"GA011",66),{"GA017",64}, {"GA018",64),{"GA016",72}}; int i; proc(stu); printf("The data after sorted:\n"); for(i=0;i<M;I++) { if(i%4= =0) //每行输出4个学生记录 printf("n"); printf("%s%4d",stu[i],num,stu[i].s); } printf("\n"); } |
查看答案 |
简答题 | 请补充函数proc(),该函数的功能是计算下面公式SN的值: SN=1+1/3十4/5+...+2N-1/SN-1 例如,当N=20时,SN=29.031674。 注意:部分源程序给出如下。 请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。 试题程序: #include #include #include double proc(int n) { double s=1.0,sl=0.0; int k; for(【1】;k<=n;k++) { s1=S; 【2】 } return 【3】 ; } void main() { int k=0: double sum; system("CLS"); printf("\nPlease input N="); scanf("%d",&k); sum=proc(k); printf("\nS=%If",sum); } |
查看答案 |
简答题 | 给定程序中,函数proc()的功能是:使数组中的元素的值缩小5倍。 请修改程序中的错误,使它能得出正确的结果。 注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include #include #include float m[10]; //****found**** int proc(void) { int j; printf("In subfunc after calling\n"); for(j=0;j<10;j++) { //****found**** printf("%f",m[j]%5); } } void main() { int i; printf("In main before calling\n"); for(i=0;i<10;i++) { m[i]=i+20; printf("%f",m[i]); } proc(); printf("\nln main after calling\n"); for(i=0;i<10;i++) printf("%f",m[i]/5); } |
查看答案 |
简答题 | 请编写函数proc(),其功能是:将str所指字符串中下标为偶数的字符删除,串中剩余字符形成的新串放在t所指数组中。 例如,当str所指字符串中的内容为abcdefg,则在t所指数组中的内容应是bdf。 注意:部分源程序给出如下。 请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的花括号中填入所编写的若干语句。 试题程序: #include #include #include #include void proc(char*str,char t[]) { } void main() { char str[100],t[100]; system("CLS"); printf("\nPlease enter string str:"); scanf("%S",str); proc(str,t); printf("\nThe result is:%s\n",t); } |
查看答案 |
简答题 | str是一个由数字和字母字符组成的字符串,由变量num传人字符串长度。请补充函数proc(),该函数的功能是:把字符串str中的数字字符转换成数字并存放到整型数组1,b中,函数返回数组bh的长度。 例如.str=”abc123de45f967”.结果为:1234567。 注意:部分源程序给出如下。 请勿改动main()函数和其他函数中的任何内容.仅在函数proc()的横线上填入所编写的若干表达式或语句。 试题程序: #include #define M 80 int bb[M]; int proc(char str[].int bh[],int num) { int i.n=0; for(i=0;i<NUM:I++) { if( 【1】 ) { bb[n]=【2】; n++: ) return 【3】 ; } void main() { char str[M]; int num=0.n,i: printf(”Enter a string:n”); gets(str); while(str[num]) num++o n=proc(str,bb,num); prinlf(”\nbb=”); for(i=0;i<N;I++) printf(”%d”,bb[i]); ) |
查看答案 |
简答题 | 下列给定程序中函数proc的功能是:取出长整型变量s中偶数位上的数,依次构成一个新数放在t中。例如,当s中的数为123456789时,t中的数为2468。请修改程序中的错误,使它能得出正确的结果。 注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include #include #include //****found**** void proc(1ong s,long t) {long s1=10; s/=10: *t=s ; //****found**** while(s<0) { s=s/100; *t=s *s1+*t; s1=s1*10: } void main() {long S,t; system(”CLs”); printf(”\nPlease enter s:”); scanf(”%ld”,&s); proc(s,&t): printf(”The result is:%ld\\n”,t); } |
查看答案 |
简答题 | 请编写函数proc(),其功能是:将str所指字符串中除下标为偶数,同时ASCII码值为奇数的字符外,其余的字符都删除,串中剩余字符所形成的一个新串放在t所指的数组中。例如,若str所指字符串中的内容为ABCDEFGl2345,其中字符8的ASCII码值为偶数,所在元素的下标为奇数,因此必须删除;而字符A的ASCII码值为奇数,所在数组中的下标为偶数,因此不应当删除。依次类推,最后t所指的数组中的内容应是ACEG。 注意:部分源程序给出如下。 请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的花括号中填入所写的若干语句。 试题程序: #include #include #include #include void proc(char*str,char t[]) { ) void main() ( char str[100],t[100]; system(”CLS”); printf(”\nPlease enter string str:"); scanf(”%s”,str); proc(str,t); printf(”\nThe result is:%s\n”,t): ) |
查看答案 |
简答题 | 请补充main()函数,该函数的功能是:把一个字符串中的所有小写字母字符全部转换成大写字母字符,其他字符不变,结果保存在原来的字符串中。 例如,当str[M]=”abcdefl23ABCD”,结果输出:“ABC DEF123ABCD”。 注意:部分源程序给出如下。 请勿改动main()函数和其他函数中的任何内容,仅在横线上填入所编写的若干表达式或语句。 试题程序: #include #include #include #define M 80 void main() { intj; char str[M]=" abcdefl23ABCD”; char *pf=str; system(”CLS”): printf(”***original string *** \n”): puts(str); 【1】 while(*(pf+j)) { if(*(pf+j)>='a' &&*(pf+j)<='Z') { *(pf+j)=【2】 ; 【3】 ; ) else j++; ) printf(”****new string****\n”); puts(str); system(”pause”);} |
查看答案 |
简答题 | 下列给定程序中,函数proc()的功能是:根据整型形參n的值,计算如下公式的值。 t=i-1/(2*2)-1/(3*3)-…-1/(n*n) 例如.当n=7时。t=0.188203。 请修改函数proc()中的错误,使它能得出正确的结果。 注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include #include #include double proc(int n) {double y=1.0; inl i; //****found**** for(i=2;i<N;I++) //****found**** y-=1/(i*i): telurn(y); } void main() { int n=7: system(”CLS”): print[(”\nThe result is%lf\n”,proe(n))。 1 |
查看答案 |
简答题 | 请编写函数proc(),它的功能是计算: s=(1-In(1)-ln(2)-In(3)-…-In(m))2 S作为函数值返回。 在C语言中可调用log(n)函数求In(n)。log函数的引用说明是double log(double x)。 例如,若m的值为10,则proc()函数值为198.934454。 注意;部分源程序给出如下。 请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的花括号中填人所编写的若干语句。 试题程序: #include #include #include #include double proc(int m) { void main() { system(”CLS”); printf(”%f\n”,proc(10)); } |
查看答案 |
简答题 | 请补充main()函数,该函数的功能是:输入两个正整数numl和num2,求这两个数的最大公约数和最小公倍数。 例如,若输人的两个正整数为12,4,则它们的最大公约数为4,最小公倍数为12。 注意:部分源程序给出如下。 请勿改动main()函数和其他函数中的任何内容,仅在main()函数的横线上填入所编写的若干表达式或语句。 试题程序: #include #include void main() { int a,b,numl,num2,t; system(”CLS”): printf(”\nlnput tWO numbers:\n”); scanf(”%d,%d”,&numl,&num2); if(numl<NUM2) { a=num2; b=numl; } else { a=num1: b=num2: ) while(【1】) { t=【2】 a=b; b=t; } printf("greatest common divisor: %d\n”,a); printf(”least common multiple: %d\n”,【3】); |
查看答案 |
简答题 | 下列给定程序中,函数proe()的功能是:对M名学生的学习成绩,按从高到低的顺序找出前m(m<10)名学生来,并将这些学生数据存放在一个动态分配的连续存储区中,此存储区的首地址作为函数值返回。 请修改程序中的错误,使它能得出正确的结果。 注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include%stdlib.h> #include #include #include #include%malloe.h> #define M 10 typedef struct ss { char num[10]; int s; } STU; STU *proc(STU a[],int m) { STU b[-M],*t; int i,j,k; //****found**** *t=calloc(m,sizeof(STU)); for(i=0;i for(k=0;k<M;K++) { for(i=j=0;i<M;I++) if(b[i].s>b[j].s)j=i; //****found**** t[k].num=b[j].num; t[k].s=b[j].S; b[j].s=0; } return t: } void outresuh(STU a[],FILE *pf) f int i; for(i=0;i<M;I++) fprintf(pf,”No=%s Mark=%d\n”, a[i] mum,a[i].s); fprintf(pf,”\n\n”); ) void main() {STU stu[M]={{¨A01”,81},{¨A02”,89}, {¨A03”,66},{”A04”,87),{”A05”,77), {”A06”,90),{"A07”,79),{”A08”,61), {”A09”,80},{”A10”,71)); STU+pOrder; int i,m; system(”CLS”); printf(”****THE RESULT****\n”); outresuh(stu,stdout); print{(”\nGive the number of the students who have better score:”); scanf(”%d”,&m); while(m>10) printf(”\nGive the number of the students who have better score:”); scanf(”%d”,&m); } p()rder=proc(stu,m); printf(”****THE RESULT****\n”); printf(”The lop:\n”); for(i=0:i<M:I++) printf(”%s%d\n”,pOrder[i].hum, pOrder[i].s); free(pOrder); ) |
查看答案 |
简答题 | 学生的记录由学号和成绩组成,M名学生的数据已在主函数中放入结构体数组stu中,请编写函数proc(),其功能是:按分数的高低排列学生的记录,高分在前。 注意:部分源程序给出如下。 请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的花括号中填入所编写的若干语句。 试题程序: # include #define M 16 typedef s truct { char num[10]; inl S; ) STREC; void proc(STREC a[]) int i,j; STREC t; for(i=1;i<M;I++)&NBSP; *用冒泡法按从高到低 排序*/ for(j=0;j<M-1;J++) if(a[j].s 的记录,高分在前*/ {t=aEP;a[j]=a[j+1];a[j+1]=t;} } void main () { STREC,sluEM]={{ ”GA005”,85),{¨GA003”, 76}, {”GA002“,69},{¨GA004”,815}.{¨GA001”,91}, {"GA007”,72},{“GA008”,64),{"GA006”,87}, {¨GA015”,85},i”GAO13”,91},{”GA012”,64}, {"GA014”,91},{”GA011”,66},{¨GA017”,64}, {”GA018”,64},{¨GA016”,72}}; in/i; proc(stu): prinlf(”The data afwr sorted:\n”); for(i=0;i<M:I++) { if(i%4==0) //每行输出4个学生记录 printf(”\n”); printf(”%sM”,stu[i].num,stu[i].s); } printf(”\n”): } |
查看答案 |
简答题 | 请补充函数proc(),其功能是:计算并输出给定10个数的方差。 例如,拾定的10个数为12.0,9.0.26.0,5.0,6.0,31.0,9.0,3.0,8.0,18、0,输出为s=8.8771500。 注意:部分源程序给出如下。 请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若于表达式或语句。 试题程序: #include #include double proc(double xElO]) { int i; double avg=0.0; double 8urn=0.0; double abs=0.0: double sd; for(i=0:i<10;i++) 【1】 ; avg=sum/10; for(i=0;i<10;i十十) 【2】 ; sd= 【3】 ; return sd; void main() { double s,str[10]={12.0,9.0,26.0,5.0,6.0,31.0.9.0,3.0,8.0,18.0); int i; printf(”\nThe original data is:\n”); for(i一0;i<10;i++) t)rintf(”%6.lf,slr[i]): printf(”\n\n”); s=proc(str): printf(”s=%f\n\n”,s); ) |
查看答案 |