填空题以下程序的输出结果是 【18】 。 #include <stdio.h> #deftne JFT(x)x*x main() int a,k=3; a=++JFT(k+1); printf("%d",a);
填空题当循环队列非空且队尾指针等于队头指针时,说明循环队列已满,不能进行入队运算。这种情况称为______。
填空题给定程序的功能是调用fun函数建立班级通讯录。通讯录中记录每位学生的编号、姓名和电话号码。班级的人数和学生的信息从键盘读入,每个人的信息作为一个数据块写到名为myfile5.dat的二进制文件中。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
不得增行或删行,也不得更改程序的结构!
给定源程序:
#include<stdio.h>
#include<stdlib.h>
#defilie N 5
typedef struct
{int num;
char name[10];
char tel[10];
}STYPE;
void cheek();
/**********found**********/
int fun(______*std)
{
/**********found**********/
______*fp;int i;
ig((fp=fopen("myfile5.dat","wb"))==NuLL)
return(0);
printf("/nOutput data to file!/n");
for(i=0;i<N;i++)
/**********found**********/
fwrite(
fclose(fp);
return(1);
}
main()
{STYPE s[10]={{1,"aaaaa","111111"},
{1,"bbbbb","222222"},{1,"ccccc","333333"},
{1,"ddddd","444444"},{1,"eeeee","555555"}};
int k;
k=fun(s);
if(k==1)
{printf("Succeed!");check();}
else
printf("Fail!");
}
void check()
{FILE *fp;int i;
STYPE s[10];
if(fp=fopen("myfile5.dat","rb"))==NULL)
{printf("Fail!!/n");exit(0);}
printf("/nRead file and output to screen:/n");
printf("/n hum name tel/n");
for(i=0;i<N;i++)
{fread(
printf("%6d %s %s/n",s[i].num,s[i].name,s[i].tel);
}
fclose(fp);
}
填空题以下程序将数组a的4个元素和数组b的6个元素写到名为lett.dat的二进制文件中,请填空。
#include <stdio.h>
#include <stdlib.h>
main()
{ FILE *fp;
char a[5]="1234",b[7]="abcedf";
if((fp=fopen("{{U}} 【9】 {{/U}}","wb"))==NULL) exit(0);
fwrite(a,sizeof(char),4,fp);
fwrite(b,{{U}} 【10】 {{/U}},1,fp);
fclose(fp);
}
填空题函数fun的功能是计算xn: double fun(double x, int n) { int i; double y=1; for(i; =1; i<=n; i++)y=y*x; return y; } 主函数中已正确定义m、a、b变量并赋值,并调用fun函数计算:m=a4+b4-(a+B)3。实现这一计算的函数调用语句为{{U}} 【12】 {{/U}}。
填空题以下程序运行后的输出结果是【 】。
void swap(int x,int y)
{ int t;
t=x;x=y;y=t;printf("%d%d",x,y);
}
main()
{ int a=3,b=4;
swap(a,b);pintf(("%d%d",a,b);
}
填空题下列给定程序中已建立一个带头结点的单向链表,链表中的各结点按结点数据域中的数据递增有序链接。函数fun()的功能是:把形参x的值放入一个新结点并插入链表中,使插入后各结点数据域中的数据仍保持递增有序。
请在标号处填入正确的内容,使程序得出正确的结果。
注意:部分源程序给出如下。不得增行或删行,也不得更改程序的结构。
试题程序 #include
<stdio.h> #include <stdlib.h> #define N
8 typedef struct list { int data;
struct list * next; } SLIST; void
fun(SLIST * h, int x) { SLIST *p, *q, *s;
s=(SLIST *)malloc(sizeof(SLIST)); s->data=______;
q=h; p=h->next; while(p!=NULL
p=p->next; } s->next=p;
q->next=______; } SLIST * creatlist(int *
a) { SLIST *h, *p, *q; int i; h=p=(SLIST *)
malloc(sizeof(SLIST)); for(i=0; i<N; i++) {
q=(SLIST *) malloc sizeof(SLIST)); q->data=a[i]; p->next=q;
p=q; } p->next=NULL; return
h; } void outlist (SLIST * h)
{ SLIST *p; p=h->next; if(p==NULL)
printf("/nThe list is NULL! /n"); else
{ printf("/nHead"); do {printf("->% d", p->data);
p=p->next; } while(p!=NULL);
printf("->End/n"); } }
main() { SLIST *head; int x; int
a[N]={11,12,15,18,19,22,25,29}; head=creatlist (a);
printf("/nThe list before inserting:/n");
outlist(head); printf("/nEnter a number:");
scanf("% d", fun(head, x);
printf("/nThe list after inserting:/n");
outlist(head); }
填空题若有下列定义(设int类型变量占两个字节),则i= 【6】 ,j= 【7】 。 int i=8,j=9;float x=123.456; print("i=%oj=%o/n",i,j);
填空题函数fun的功能是计算xn double fun(double x,int n) int i; double y=1; for(i=1;i<=n;i++) y=y*x; return y; 主函数中已正确定义m、a、b变量并赋值,而且调用fun函数计算:m=a4+b4-(a+b)3。实现这一计算的函数调用语句为______。
填空题在给定程序中,函数fun的功能是:找出形参s所指字符串中出现频率最高的字母(不区分大小写),并统计出其出现的次数。 例如,形参s所指的字符串为:abcAbsmaxless,程序执行后的输出结果为: letter 'a':3 times letter 's':3 times 请在程序的下画线处填入正确的内容并把下画线删除,使程序得出正确的结果。 注意:源程序存放在考生文件夹下的BLANK1.C中。不得增行或删行,也不得更改程序的结构。 文件BLANK1.C内容如下: #include<stdio.h> #include<string.h> #include<ctype.h> void fun(char *s) int k[26]=0,n,i,max=0;char ch; while(*s) if(isalpha(*s)) /**********found**********/ ch=tolower( (1) ); n=ch-'a': /**********found**********/ k[n]+= (2) ; s++: /**********found**********/ if(max (3) ; printf("/nAfter count: /n"); for(i=0;i<26;i++) if(k[i]==max)printf("/nletter /'%c/': %d times/n",i+'a',k[i]); void main( ) char s[81]; printf("/nEnter a string: /n/n"); gets(s); fun(s);
填空题下列程序的运行结果为{{U}} 【7】 {{/U}}。
#include<math.h>
#include<stdio.h>
main()
{ int s=1;
float n=1,pi=0;
double t=1;
while(fabs(t)>=2e-6)
{ pi+=t;
n+=2;
s=-s;
t=s/n;
}
pi*=4;
printf("pi=%.6f/n",pi);
}
填空题设函数findbig已定义为求3个数中的最大值,以下程序将利用函数指针调用findbig函数。请填空。 main() int findbig(int,int,int); int(*f)(),x,y,z,big; f= 【15】 。 scanf("%d %d %d", big=(*f)(x,y,z); printf("big=%d/n",big);
填空题以下fun函数的功能是:累加数组元素中的值,n为数组中元素的个数。累加的和值放入x所指的存储单元中。补足所缺语句。 fun(int b[],int n,int *x) int k,r=0; for(k=0;k<n;k++)r= 【15】 ; 【16】 =r;
填空题以下程序中,主函数调用了LineMax函数,实现在N行M列的二维数组中,找出每一行上的最大值。
请填空。
#define N 3
#define M 4
void LineMax(int x[N][M])
{ int i,j,P;
for(i=0;i<N;i++)
{ p=0;
for(j=1;j<M;j++)
if(x[i][p]<x[i][j]){{U}} 【9】 {{/U}};
printf("The max value in line %d is %d/n",i,{{U}} 【10】 {{/U}});
}
main()
{ int x[N][M]={1,5,7,4,2,6,4,3,8,2,3,1};
{{U}} 【11】 {{/U}};
}
填空题下列给定程序的功能是:从键盘输入若干行字符串(每行不超过80个字符),写入文件myfile4.txt中,用-1作字符串输入结束的标志,然后将文件的内容显示在屏幕上。文件的读写分别由函数ReadText和writeText实现。
请在程序的下画线处填入正确的内容并将下画线删除,使程序得出正确的结果。
注意:部分源程序在文件BLANK1.C中。
不得增行或删行,也不得更改程序的结构!
#include<stdio.h>
#include<string.h>
#nclude <stdlib.h>
void WriteText(FILE *);
void ReadText(FILE *);
main( )
{ FILE * fp;
if((fp=fopen(”myiile4.txt","w"))==NULL)
{printf("open fail!!/n");exit(0);}
WriteText(fp);
fclose(fp);
if((fp=fopen("myfile4.txt","r"))==NULL)
{printf("open fail!!/n");exit(0);}
ReadText(fp);
fclose(fp);
}
/* * * * * * * * * *found* * * * * * * * * */
void WriteText(FILE ______)
{ char str[81];
printf("/nEnter string with-1 to end :/n");
gets(str);
while(strcmp(str,"-1")!=0){
/* * * * * * * * * *found* * * * * * * * * */
fputs(______,fw);fputs("/n",fw);
gets(str);
}
}
void ReadText(FILE *fr)
{ char str[81];
printf("/nRead file and output to screen:/n");
fgets(str,81,fr);
while(!feof(fr)){
/* * * * * * * * * *found* * * * * * * * * */
printf("%s",______);
fgets(str,81,fr);
}
}
填空题设有定义语句:int a[][3]=0,1,2;,则数组元素a[1][2]的值为______。
填空题下列执行后输出的结果是{{U}} {{/U}}。 main() intarr[10],i,k=0 for(i=0;i<10;i++)atr[i]=i for(i=1,i<4;i++) k+=arr[i]+i; printf("%d//n",k);
填空题请补充函数fun(),该函数的功能是:把一个整数转换成字符串,并倒序保存在字符数组str中。例如:当n=13572468时,str=-“86427531”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio.h>
#include <conio.h>
#define N 80
char str[N];
void fun(long int n)
{
int i=0;
while({{U}} 【1】 {{/U}})
{
str[i]={{U}} 【2】 {{/U}};
n/=10;
i++;
}
{{U}}【3】 {{/U}};
}
main()
{
long int n=13572468;
clrscr();
printf("*** the origial data ***/n");
printf("n=%ld",n);
fun(n);
printf("/n%s",str);
}
填空题以下程序的运行结果是______。
# include <string.h>
typedef struct student
{ char name[10];
long sno;
float score;} STU;
main()
{ STU a= {"Liuyifei",2001,95},b={"Shangxian",2002,90},c= {"Zhangli",2003,95 },d,*p=
d=a;
if(strcmp(a.name,b.name)>0) d=b;
if(strcmp(c.name,d.name)>0) d=c;
printf("%ld%s/n",d.sno,p->name);
}
填空题下列程序从名为filea.dat的文本文件中逐个读入字符并显示在屏幕上。请填空。
#include <stdio.h>
main()
{ FILE *fp; char ch;
fp = fopen( 【 】 );
ch = fgetc(fp);
while(!feof(fp)) { putchar(ch); ch=fgetc(fp); }
putchar("\n"); fclose(fp);
}
