填空题若变量已正确定义,要通过以下语句给a、b、c、d分别输入字符A、B、C、D,给w、x、y、z分别输入整数10、20、30、40,正确的输入形式是______,请用<CR>代表Enter键。
scanf("%d%c%d%c%d%c%d%c",
填空题在线性结构中,第一个结点没有前驱结点,其余每个结点有且只有 【1】 个前驱结点;最后一个结点没有后继结点,其余每个结点有且只有 【2】 个后继结点。
填空题下面程序的运行结果是{{U}} 【18】 {{/U}}。
#inelude <stdio.h>
int f(int a[],int n)
{ if(n>1) return a[0]+f(
else return a[0];
}
main()
{ int aa[3]={1,2,3},s;
s=f( printf("% d/n",s);
}
填空题以下程序运行后的输出结果是______。 #include <string.h> main() char ch[]="abc",x[3][4];int i; for(i=0;i<3;i++) strcpy(x[i],ch); for(i=0;i<3;i++)printf("%s", printf("/n");
填空题请补充main()函数,该函数的功能是:从键盘输入一个字符串并保存在字符str1中,把字符串str1中下标为偶数的字符保存在字符串str2中并输出。例如,当str1="computer",则str2="cmue"。
注意:部分源程序给出如下。
请勿改动函数中的任何内容,仅在横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#define LEN 80
void main()
{
char str1[LEN],str2[LEN];
char*p1=str1,*p2=str2;
int i=0,j=0;
system("CLS");
printf("Enter the string:/n");
scanf(______);
printf("***the origial string***/n");
while(*(p1+j))
{
printf("______",*(p1+j));
j++;
}
for(i=0;i<j;i+=2)
*p2++=*(str1+i);
*p2="/0";
printf("/nThe new string is:%s/n",______);
}
填空题设x为int型变量,请写出一个关系表达式______,用以判断x同时为3和7的倍数时,关系表达式的值为真。
填空题数据库存管理系统常见的灵敏据模型有层次、网状和{{U}} 【8】 {{/U}}三种。
填空题有以下程序:
#include <stdio.h>
void f(int y,int *x)
{ y=y+ *x; *x=*x+y;}
main()
{ int x=2,y=4;
f(y,
printf("%d%d/n",x,Y);
}
执行后的输出结果{{U}} 【6】 {{/U}}。
填空题以下程序将两个数从小到大输出。请填空。
{ float a,b,{{U}} 【8】 {{/U}};
scanf(,{{U}}【9】 {{/U}}& a,& b);
if(a>b)
{t=a;
{{U}} 【10】 {{/U}};
b=t;
printf("%5.2f%5.2f/n",a,b);
}
填空题以下程序输出的结果是 【8】 。 main() int a=5,b=4,c=3,d; d=(a>b>c); printf("%d/n",d);
填空题给定程序MODI1.C中函数fun的功能是根据整型形参m的值,计算如下公式的值。例如,若m中的值为5,则应输出0.536389。请改正程序中的错误,使它能得出正确的结果。注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!给定源程序如下。#include<stdio.h>doublefun(intm){doubley=1.0;inti;/*********found********/for(i=2;i<m;i++)/**********found********/y-=1/(i*i);return(y);}main(){intn=5;printf("/nTheresultis%lf/n",fun(n));}
填空题以下程序通过函数sunFun求f(x)。这里f(x)=x2+1,由F函数实现。请填空。main(){printf("Thesum=%d/n",SunFun(10));}SunFun(intn){intx,s=0;for(x=0;x<=n;x++)s+=F(______);returns;}F(intx){return(______);}
填空题下面程序的输出是{{U}} 【9】 {{/U}}。
main()
{enum em{em1=3,em2=l,em3};
char*aa[]={"AA","BB","CC","DD"};
printf("%s%s/n",aa[eml],aa[em2],aa[em3]);
}
填空题下列给定程序的功能是:建立一个带头结点的单向链表,并用随机函数为各结点数据域赋值。函数fun的作用是求出单向链表结点(不包括头结点)数据域中的最大值,并且作为函数值返回。
请改正函数fun中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
typedef struct aa
{int data;
struct aa*next;
}NODE;
fun(NODE*h)
{int max=-1;
NODE * p;
/*********found*********/
p=h;
while(p)
{if(p->data>max)
max=p->data;
/*********found*********/
p=h->next;
}
return max;
}
outresult(int s,FILE * pf)
{fprintf(pf,"/nThe max in link:%d/n",s);
}
NODE*creatlink(int n,int m)
{NODE*h,*p,*s;
int i;
h=p=(NODE*)malloc(sizeof(NODE));
h->data=9999;
for(i=1;i<=n;i++)
{s=(NODE*)malloc(sizeof(NODE));
s->data=rand()%m;
s->next=p->next;
p->next=s;p=p->next;
}
p->next=NULL;
return h;
}
outlink(NODE *h,FILE * pf)
{NODE * p;
p=h->next;
fprintf(pf,"/n The LIST:/n/nHEAD");
while(p)
{fprintf(pf,"->%d",p->data);
p=p->next;}
fprintf(pf,"/n");
}
main()
{NODE*head;int m;
system("CLS");
head=creatlink(12,100);
outlink(head,stdout);
m=fun(head);
printf("/nThe RESULT:/n");
outresult(m,stdout);
}
填空题str为一个字符序列。请补充函数fun(),该函数的功能是:查找str中值为x的元素,返回该字符序列中值为x的元素个数,并把这些值为x的元素下标依次保存在数组bb中。例如,在“abcdefahij”中查找‘a’,结果为:2个‘a’,下标依次为 0、6。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#define N 20
int bb[N];
int fun(char *str,char ch)
{
int i=0, n=0;
char t=ch;
char *p=str;
while(*p)
{
if ({{U}} 【1】 {{/U}})
{{U}}【2】 {{/U}};
p++;
i++;
}
return{{U}} 【3】 {{/U}};
}
main()
{
char str[N];
char ch;
int i, j,n;
clrscr();
printf("***Input the original string
***/n");
gets(str);
printf("***The Original ***/n");
puts(str);
printf("***Input character ***/n");
scanf("%c",
n=fun(str,ch);
printf("/nThe numbr of character is:
%d/n", n);
printf{"***The suffix of character
***/n");
for(i=0;i<n;i++)
printf("%d ",bb[i]);
}
填空题给定程序通过定义并赋初值的方式,利用结构体变量存储了一名学生的学号、姓名和3门课的成绩。函数fun()的功能是将该学生的各科成绩都乘以一个系数a。请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 #include<stdio.h> typedef struct int num; char name[9]; float score[3]; STU; void show(STU tt) int i; pfintf("%d %s:",tt.num,tt.name); for(i=0;i<3;i++) printf("%5.1f",tt.score[i]); printf("/n"); /**********found**********/ void modify( (1) *ss,float a) int i; for(i=0;i<3;i++) /**********found**********/ ss-> (2) *=a; main() STU std=1,"Zhanghua",76.5,78.0,82.0); float a; printf("/aThe original number and name and scores:/a"); show(std); printf("/aInput a number:");scanf("%f", /**********found**********/ modify( (3) ,a); printf("/nA result of modifying:/n"); show(std);
填空题请补充main()函数,该函数的功能是:把一个字符串中的所有小写字母字符全部转换成大写字母字符,其他字符不变,结果保存在原来的字符串中。
例如,当str[M]="abcdef123ABCD",结果输出:“ABCDEF123ABCD”。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#define M 80
void main()
{
int j;
char str[M]="abcdef123ABCD";
char *pf=str;
system("CLS");
printf("***original string***/n");
puts(str);
______
while(*(pf+j))
{
if(*(pf+j)>="a"
______;
}
else
j++;
}
printf("****new string****/n");
puts(str);
system("pause"); }
填空题有以下语句段: int n1=10,n2=20; printf(" 【15】 ",n1,n2); 要求按以下格式输出n1和n2的值: n1=10 n2=20每个输出行从第一列开始,请填空。
填空题请补充函数proc(),该函数的功能是:交换数组aa中最大和最两个元素的位置,结果依然保存在原数组中,其他元素位置不变。注意数组aa中没有相同元素。
例如,输入“10,20,230,40,50,60,70,80,90,56”,则输出“90,20,30,40,50,60,70,80,10,56”。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#define M 10
void proc(im aa[])
{
int i, t;
int max=0, min=0;
for(i=0; i<M; i++)
{
if(______)
max=i;
if(______)
min=i;
}
t=aa[max];
______;
aa[min]=t;
}
void main()
{
int i;
int aa[M]={10, 20, 30, 40, 50, 60, 70, 80, 90, 56};
system("CLS");
printf("/n***original list***/n");
for(i=0; i<M; i++)
printf("%4d", aa[i]);
proc(aa);
printf("/n***new list***/n");
for(i=0; i<M; i++)
printf("%4d", aa[i]);
}
填空题甲、乙、丙、丁4人同时开始放鞭炮,甲每隔t1秒放一次,乙每隔t2秒放一次,丙每隔t3秒放一次,丁每隔t4秒放一次,每人各放n次。函数fun的功能是根据形参炸响,只算一次响声,第一次响声是在第0秒。
例如,若t1=7,t2=5,t3=6,t4=4,n=10,则总共可听到28次鞭炮声。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
/**********found**********/
#define OK(i, t, n((______%t==0)
if(maxt<t2)maxt=t2;
if(maxt<t3)maxt=t3;
if(maxt<t4)maxt=t4;
count=1; /*给count赋初值*/
/**********found**********/
for(t=1; t<maxt*(n-1); ______)
{
if(OK(t, t1, n)||OK(t, t2, n)||OK(t, t3, n)||OK(t, t4, n))
count++;
}
/**********found**********/
return______;
}
main()
{int t1=7, t2=5, t3=6, t4=4, n=10, r;
r=fun(t1, t2, t3, t4, n);
printf("The sound:%d/n", r);
}
