填空题以下程序运行后的输出结果是______。
main()
{ int a[4][4]={{1,2,3,4},{5,6,7,8},{11,12,13,14},{15,16,17,18}};
int i=0,j=0,s=0;
while (i++<4)
{ if(i==2||i==4) continue;
j=0;
do { s+=a[i][j]; j++;}while(j<4);
}
printf("%d/n",s);
}
填空题下列程序的输出结果是______。
#include<stdio.h>
main()
{int x=10,y=10,i;
for(i=0;x>8;y=++i)
printf("%d%d",x--,y);
}
填空题数据结构分为逻辑结构和存储结构,循环队列属于 【2】 结构。
填空题若x为int类型,请写出与!x等价的C语言表达式______。
填空题请补充main()函数,该函数的功能是:先以只写方式打开文件file.dat,再把字符串s中的字符保存到这个磁盘文件中。请勿改动main()函数与其他函数中的任何内容,仅在的横线上填写所需的若干表达式或语句。
注意:部分源程序给出如下。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#define N 100
void main()
{
FILE*f;
int i=0;
char ch;
chair s[N]="Welcome!";
if((f=fopen|("______", "w"))==NULL)
{
printf("cartnot open file.dat/n");
exit(0);
}
while(s[i])
{
ch=s[i];
______;
putchar(ch);
i++;
}
______;
}
填空题有以下程序段,且变量已正确定义和赋值。
for(s=1.0, k=1; k<=n;k++) s=s+1.0/(k*(k/1));
printf("s=%f/n/",s);
请填空,使下面程序段的功能与之完全相同。
s=1.0; k=1;
while({{U}} 【10】 {{/U}}) { s=s+1.0/(k*(k+1)); {{U}}【11】 {{/U}}; }
printf("s-=%f/n/n",s);
填空题给定程序MODI1.C中函数fun的功能是计算n!。
例如,给n输入5,则输出120.000000。
请改正程序中的错误,使程序能输出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
给定源程序如下。
#include<stdio.h>
double fun(int n)
{ double result=1.0;
/************found***************/,
if n==0
return 1.0;
while(n>1
}
main()
{ int n;
printf("Input N:");
scanf("%d",
printf("/n/n%d!=%lf/n/n",n,fun(n));
}
填空题执行以下程序后的输出结果是 【6】 。 main() int a=10; a=(3*5,a+4); printf("a=%d/n",a);
填空题以下程序运行后的输出结果是 【13】 。 #include <stdio.h> main( ) int a,b,c; a =25;b =025;e =0x25; prinff("%d %d %d/n",a,h,c);
填空题以下程序的输出结果是{{U}} 【12】 {{/U}}。
main()
{ char *p=“abodefgh”,*r;
long *q;
q=(long*)p;
q++;
r=(char*)q;
printf(“%s/n”,r);
}
填空题以下程序运行后的输出结果是______。 main() char a[]="123456Y89",*p; int i=0; p=a; while(*p) if(i%2=0) *p='*'; p++;i++; puts(a);
填空题计算机软件分为系统软件和应用软件,UNIX系统属于{{U}} 【4】 {{/U}} 。
填空题请补充main函数,该函数的功能是求方程ax2+bx+c=0的两个实数根。方程的系数a、b、c从键盘输入,如果判别式 (disc=b2-4ac)小于0,则要求重新输入a、b、c的值。 例如,当a=1,b=2,c=1时,方程的两个根分别是x1=-1.00, x2=-1.00。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。 试题程序: #include"math.h" #include <stdio.h> main() float a,b,C,disc,X1,x2; clrscr(); do printf("Input a,b,C:"); scanf("%f,%f,%f",&a,&b,ac); disc=b*b-4*a*c; if(disc<0) printf("disc=%f/n Input again! /n",disc); while( 【1】 ); printf("****+* the result *+*****/n"); x1= 【2】 ; x2= 【3】 ; printf("/nx1=%6.2f/nx2=%6.2f/n",x1/x2);
填空题以下程序中,for循环体执行的次数是 {{U}} 【13】 {{/U}} 。
#define N 2
#define M N+1
#define K M+1*M/2
main( )
{ int i;
for(i=1;i〈 K;i++)
{ ... }
...
}
填空题请补充main函数,该函数的功能是:输出一个NXN矩阵,要求非周边元素赋值0,周边元素赋值1。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。 试题程序: #include<stdio .h> #define N 10 main() int bb[N] IN]; iht i,j,n; clrscr 0; printf (" /nInput n: /n"); scanf ("%d", for (i=0; i<n; i++ ) for (j=0; j<n; j++) if(【1】) bb[i] [j]=l; else 【2】; printf(" /n*** the result *** /n"); for (i=0; i<n; i++) printf (" /n/n"); for (j=0; j<n; j++) printf ("%4d",bb [i] [j ] );
填空题下列给定程序中,函数fun的功能是:计算整数n的阶乘。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include<stdlib.h> #include<stdio.h> double fun(int n) double result=1.0; while(n>1&&n<170) /*********found************/ result*=--n; /***********found*********/ Return; voidmain() int n; system("CLS"); printf("Enter an integer:"); scanf("%d",&n); printf("/n/n%d!=%1d/n/n",n,fun(n));
填空题下列程序的功能是:求出ss所指字符串中指定字符的个数,并返回此值。例如,若输入字符串123412132,指定字符1,则输出3。请填空。 #include<conio.h> #include<stdio.h> #define M 81 int fun(char *ss,char c) int i=0; for(;______;ss++) if( *ss==c)i++: return i; main( ) char a[M],ch; printf("/nPlease enter a string:");gets(a); printf("/nPlease enter a char:");ch=getchar( ); prinff("/nThe number of the char is:%d/n",fun(a,ch));
填空题设有以下定义变量的语句,并且已赋确定的值,则表达式“W*X+Z-y”所求得的数据类型为{{U}} {{U}} {{/U}} {{/U}}。
char w;int x;float y;double 2;
填空题给定程序中,函数fun的功能是:将形参s所指字符串中的所有数字字符顺序前移,其他字符顺序后移,处理后新字符串的首地址作为函数值返回。 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 注意:部分源程序给出如下。 不得增行或删行,也不得更改程序的结构! 试题程序: #include <stdio.h> #include <string.h> #include <stdlib.h< #include <ctype.h< char *fun(char *s) inti, j, k, n; char *p, *t; n=strlen(s)+1; t=(c har*)malloc (n*sizeof(char)); p=(char*)malloc(n*sizeof(char)); j=0; k=0; for(i=0; i<n; i++) if(isdigit(s[i])) /******************found*******************/ p[ (1) ]=s[i]; j++; else t[k]=s[i]; k++; /******************found*******************/ for(i=0; i< (2) ; i++)p[j+i]=t[i]; p[j+k]=0; /******************found*******************/ return (3) ; main() char s[80]; printf("Please input:"); scanf("%s", s); printf("/nThe result is: %s/n", fun(s));
填空题已知字母A的ASCII码为65。以下程序运行后的输出结果是{{U}} 【11】 {{/U}}。
main()
{ char a,b;
a='A'+'5'-'3';b=a+'6'-'2';
printf("%d %c/n",a,B) ;
}
