填空题以下程序运行后的输出结果是{{U}} 【15】 {{/U}}。
void fun()
{
static int a=0;
a+=2;printf("%d",A) ;
}
main()
{ int cc;
for(cc=1;cc<4,cc++)fun();
printf("/n");
}
填空题下列程序的输出结果是{{U}} 【6】 {{/U}} 。
main()
{
int a=1,b=2;
a=a+b;b=a-b;a=a-b;
printf("%d,%d/n",a,b) ;
}
填空题有以下程序,若运时从键盘输入:18 ,11<回车>,则程序的输出结果是______。 main() int a,b; printf("Enter a,b:”);scanf("%d,%d",&a, &b); while(a!=b) while(a>b)a-=b; while(b>a)b-=a; printf("%3d%3d/n" ,a,b);
填空题若已知a=10,b=20,则表达式! a<b的值为{{U}} 【13】 {{/U}}。
填空题已有定义如下:
struct node
{ int data;
struct node *next;
} *p;
以下语句调用malloc函数,使指针p指向一个具有struct node类型的动态存储空间。请填空。
p=(struct node *)malloc({{U}} 【19】 {{/U}});
填空题以下程序把3个NODETYPE型的变量链接成一个简单的链表,并在while循环中输出链表结点数据域中的数据。请填空。 #include<stdio.h> struct node int data; struct node *next; ; typedef struct node NODETYPE; main() NODETYPE a, b, c, *h, *p; a.data=10;b.data=20;c.data=30; h= b.next=b.next=c.next='/0'; p=h; while(p)printf("%d", p->data);______;
填空题给定程序中,函数fun的功能是:计算下式前n项的和作为函数值返回。例如,当形参n的值为10时,函数返回-0.204491。请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。注意:源程序存放在下的BLANK1.C中。不得增行或删行,也不得更改程序的结构!给定源程序:#include<stdio.h>doublefun(intn){inti,k;doubles,t;s=0;/**********found**********/k=____________;for(i=1;i<=n;i++){/**********found**********/t=____________;s=s+k*(2*i-1)*(2*i+1)/(t*t);/**********found**********/k=k*____________;}returns;}main(){intn=-1;while(n<0){pfintf("Pleaseinput(n>0):");scanf("%d",}printf("/nTheresultis:%f/n",fun(n));}
填空题若有定义:int a[4][4]={{1,2,3,4},{0},{4,6,8,10},<1,3,5,7}},则初始化后,a[2][2]得到的初值是______。
填空题以下函数用来求出两整数之和,并通过形参将结果传回,请填空。 void func(int x,int y, 【13】 z) *z=x+y;
填空题若有定义:int a=4,b=5,c=6;然后顺序执行下列语句后,变量b中的值是______。c=(a-=(b-5));c=(a%3)+(b=1);
填空题程序通过定义学生结构体变量,存储了学生的学号、姓名和三门课的成绩。所有学生数据均以二进制方式输出到文件中。函数fun的功能是重写形参filename所指文件中最后一个学生的数据,即用新的学生数据覆盖该学生原来的数据,其他学生的数据不变。
请在程序的下划线处填入正确的内容,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
#define N 5
typedef struct student{
long sno;
char name[10];
float score[3];
}STU;
void fun(char*filename,STU n)
(FILE*fp;
/**********found**********/
fp=fopen(______,"rb+");
/**********found**********/
fseek(______,-(long)sizeof(STU),SEEK_END);
/**********found**********/
fwrite(
fclose(fp);
}
main()
(STU t[N]={{10001,"MaChao",91,92,77},{10002,"CaoKai",75,60,88},{10003,"LiSi",85,70,78},{10004,"FangFang",90,82,87},{10005,"ZhangSan",95,80,88}};
STU n={10006,"ZhaoSi",55,70,68},ss[N];
inti,j; FILE*fp;
fp=fopen("student.dat","wb");
fwrite(t,sizeof(STU),N,fp);
fclose(fp);
fp=fopen("student.dat","rb");
fread(ss,sizeof(STU),N,fp);
fclose(fp);
printf("/nThe original data:/n/n");
for(j=0; j<N; j++)
{printf("/nNo:%ld Name:%-8s Scores:",ss[j]. sno,ss[j].name);
for(i=0;i<3;i++)
printf("%6.2f"ss[j].score[i]);
printf("/n");
}
fun("student.dat",n);
printf("/nThe data after modifing:/n/n");
fp=fopen("student.dat","rb");
fread(ss,sizeof(STU),N,fp);
fclose(fp);
for (j=0; j<N;j++)
{printf("/nNo:%ld Name:%-8s Scores:",ss[j]. sno,ss[j].name);
for(i=0; i<3;i++)
printf(“%6.2f“. ss[j].score[i];
printf(:/n");
}
}
填空题下列程序的输出结果是______。 #include<stdio.h> int(int x,int y,int cp,int dp) cp=x*x+y*y; dp=x*x-y*y; main() int a=1,b=8,c=7,d=9; t(a,b,c,d); printf("%d%d/n",c,d);
填空题先有两个C程序文件T18.c和myfun.c同在TC系统目录(文件夹)下,其中T18.c文件如下:
#include<stdio.h>
#include "myfun.c"
main()
{ fun(); printf"/n");}
myfun.c 文件如下:
void fun()
{ char s[80],c; int n=0;
while((c=getchar())!='/n') s[n++]=c;
n-;
while(n>=O) printf("%c",s[n-]);
}
当编译连接通过后,运行程序T18时,输入Thank!则输出结果是:{{U}} [11] {{/U}}。
填空题若已经定义int a=25,b=14,c=19;,以下三目运算符(?:)所构成的语句的执行结果是{{U}} 【9】 {{/U}}。
a++<=2&&b--<=2&&c++? printf("***
a=%d,b=%d,c=%d/n",a,b,C) :printf("a=%d,b=%d,c=%d/n",a,b,C) ;
填空题文件操作步骤通常是:打开、操作和______。
填空题程序通过定义学生结构体变量,存储学生的学号、姓名和三门课的成绩。函数fun的功能是:将形参a中的数据进行修改,把修改后的数据作为函数值返回主函数进行输出。
例如,若传给形参a的数据中学号、姓名和三门课的成绩依次是:10001、“ZhangSan”、95、80、88,修改后的数据应为:10002、“LiSi”、96、81、89。
请在下划线处填入正确的内容并将下划线删除,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
#include<string.h>
struct student{
long sno;
char name[10];
float score[3];
};
/**********found**********/
______ fun(struct student a)
{int i;
a.sno=10002;
/**********found**********/
strcpy(______, "LiSi");
/**********found**********/
for(i=0; i<3; i++)______+=1;
return a;
}
main()
{struct student s=[10001, "ZhangSan", 95, 80, 88}, t;
int i;
printf("/n/nThe original data:/n");
printf("/nNo:%ld Name:%s/nScores:", s.sno, S.name);
for(i=0; i<3; i++)
printf("%6.2f", s.score[i]);
printf("/n");
t=fun(s);
printf("/nThe data after modified:/n");
printf("/nNo:%ld Name:%s/nScores:", t.sno, t.name);
for(i=0; i<3; i++)
printf("%6.2f", t.score[i]);
printf("/n");
}
填空题函数count(head)统计链表的结点个数,head为表头指针,阅读程序,要求将整个if语句改成while循环控制结构,其形式为 【9】 。 #include<stdio.h> int count(NODE*head) int n=0; if(head!=NULL) do n++; head=head->next; while(head!=NULL); return n;
填空题以下fun函数的功能是:找出具有N个元素的一维数组中的最小值,并作为函数值返回。请填空。(设N已定义)
int fun(int x[N]){
int i, k=0;
for(i=0; i<N; i++)
if(x[i]<x[k]) k=______;
return x[k];
}
填空题有以下程序
#include<stdio.h>
main()
{int x,y;
scarf("%2d%1d",&x,&y);printf("%d/n",x+y);
}
程序运行时输入:1234567,程序的运行结果是{{U}} (7) {{/U}}。
填空题阅读下面语句,则程序的执行结果是______。 #include "stdio.h" main() int a=-1,b=1,k; if(++a<0)&&!(b--<=0)) printf("%d,%d/n",a,b); else printf("%d,%d/n",b,a);
