填空题有以下程序:
int sub(int n) { return(n/10+n%10); }
main()
{int x,y;
scanf("%d",&x);
y=sub(sub(sub(x)));
printf("%d/n",y);
}
若运行时输入1234<回车>,程序的输出结果是{{U}} 【12】 {{/U}}。
填空题下面程序的运行结果是______。 void swap(int *a,int *b) int *tp; t=a;a=b;b=t; main() int x=3,y=5,*p= swap(p,q); printf("%d%d/n",*p,*q);
填空题下列给定程序中函数fun的功能是:将s所指字符串中出现的与t1所指字符串相同的子串全部替换为t2所指字符串,所形成的新串放在w所指的数组中。要求t1和t2所指字符串的长度相同。
例如,当s所指字符串中的内容为“abcdabfab”,t1所指子串中的内容为“ab”,t2所指子串中的内容为“99”时,在W所指的数组中的内容应为“99cd99f99”。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
void fun(char *s, char *t1, char *t2, char *w)
{
char *p, *r, *a;
strcpy(w, s);
while(*w)
{
p=w; r=t1;
/**********found**********/
while(r)
if(*r==*p){r++; p++;}
else break;
if(*r=="/0")
{
a=w; r=t2;
while(*r)
/**********found**********/
{*a=*r; a++; r++}
w+=strlen(t2);
}
else w++;
}
}
void main()
{
char s[100], t1[100], t2[100], w[100];
system("CLS");
printf("/nPlease enter string S:");
scanf("%s", s);
printf("/nPlease enter substring t1:");
scanf("%s", t1);
printf("/nPlease enter substring t2:");
scanf("%s", t2);
if(strlen(t1)==strlen(t2))
{
fun(s, t1, t2, w);
printf("/ne result is:%s/n", w);
}
else
printf("Error:strlen(t2)/n");
}
填空题执行以下程序的输出结果是{{U}} 【18】 {{/U}}。
#include <stdio.h>
main()
[ int i, n[4]={1};
for(i= 1 ;i<=3 ;i++)
{ n[i]=n[i-1]*2+1; printf("%d",n[i]); }
填空题下列给定程序中,函数fun()的功能是:实现两个变量值的交换,规定不允许增加语句和表达式。
例如,变量a中的值原为8,b中的值原为3,程序运行后,a中的值为3,b中的值为8。
请改正程序中的错误,使它得出正确的结果。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
int fun(int*x,int y)
{
int t;
//****found****
t=x;x=y;
//****found****
return(y);
}
void main()
{
int a=3,b=8;
system("CLS");
printf("%d%d/n",a,b);
b=fun(
printf("%d%d/n",a,b);
}
填空题请补充main函数,该函数的功能是:把字符串str1中的非空格字符拷贝到字符串str2中。
例如,若sffl=“glad to see you!”,
则str2=“gladtoseeyou!”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#define N 80
main()
{
static char strl [N] ="glad to see you!";
char str2 IN];
int i=0, j=0;
clrscr ();
printf("/n***** strl*****/n ");
puts (str1);
while (str1 [i] )
{
if({{U}}【1】{{/U}})
str2 [J++] =strl [i];
{{U}}【2】{{/U}};
}
printf("/n***** str2 *****/n ");
for (i=0; i<j; i++)
printf ("%c", str2 [i] );
}
填空题下列给定程序中,proc()函数的功能是:根据形参n,计算下列公式的值:
t=1-1/2+1/3-1/4+…+(-1)(n+1)/n
例如,若输入6,则应输出0.616667。
请修改程序中的错误,使它能得到正确结果。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
//****found****
int proc(int n)
{
double t=1.0,j=1.0;
int i;
//****found****
for(i=1;i<n;i++)
{j=-1*j;t+=j/i;}
return t;
}
void main()
{
int n;
system("CLS");
printf("/nPlease enter 1 integer number:");
scanf("%d",
printf("/nThe result is%1f/n",proc(n));}
填空题设x、y、z均为int型变量,请写出描述"x或y中至少有一个小于z"的表达式______。
填空题以下程序的功能是将字符串s中的数字字符放入d数组中,最后输出d中的字符串。例如,输入字符串 :abc123edf456gh,执行程序后输出:123456请填空. #include <stdio.h> #include <ctype.h> main() char s[80], d[80]; int i,j; gets(s); for (i=j=0;s[i]!='/0';i++) if( ) d[j]=s[i]; j++; d[j]='/0'; puts (d);
填空题以下说明语句中,______是结构体类型名。 typedef struct int n; char ch[8]; PER;
填空题以下程序从终端读入数据到数组中,统计其中正数的个数,并计算它们之和。请填空。 main() int i, a[20],sum, count; sum=count=0; for (i=0;i<20; i++) scanf("%d",(______); for(i=0;i<20; i++) if(a[i]>0) count++; sum+=(______); print f ( "sum=%d,count-%dkn" , sum, count);
填空题有以下程序: #include<stdio.h> main() int i,j,a[][3]=1,2,3,4,5,6,7,8,9; for(i=0;i<3;i++) for(j=i;j<3;j++)printf("%d",a[i][j]); printf("/n"); 程序运行后的输出结果是______。
填空题在关系模型中,把数据看成是二维表,每—个二维表称为—个{{U}} [3] {{/U}}。
填空题用高级语言编写的程序称为______程序,它可以通过解释程序翻译一句执行一句的方式执行,也可以通过编译程序一次翻译产生目标程序,然后执行。
填空题在给定程序中,函数fun的功能是:将形参n所指变量中的每一位为偶数的数去除,剩余的数按原来高位到低位的顺序组成一个新的数,并通过形参指针n传回所指变量。 例如,输入一个数:13245698,新的数为:1359。 请在程序的下画线处填入正确的内容并把下画线删除,使程序得出正确的结果。 注意:源程序是考生文件夹下的BLANK1.C。不得增行或删行,也不得更改程序的结构。 文件BLANK1.C内容如下: #include<stdio.h> void fun(unsigned long *n) unsigned long x=0,i; int t; i=1; while(*n) /**********found**********/ t=*n% (1) ; /**********found**********/ if(t%2!= (2) ) x=x+t*i:i=i*10: *n=*n/10: /***********found**********/ *n= (3) ; void main( ) unsigned long n; printf("Please input(0<n<100000000):"); scanf("%1d",&n); fun(&n); printf("/nThe result is:%1d/n",n);
填空题下列程序用来将从键盘上输入的2个字符串进行比较,然后输出2个字符串中第1个不相同字符的ASCII码之差。例如,输入的2个字符串分别为abcdef和abceef,则输出为-1。 #include main () char str [100], str2 [100], c; int i,s; printf("/n input string 1:/n"); gest(str1); printf("/n input string 2:/n"); gest(str2); i=0; while((strl[i]==str2[i] s= 【7】 ; printf(.%d/n",s);
填空题给定程序中函数fun的功能是:判断一个整数是否是素数,若是返回1,否则返回0。在main()函数中,若fun返回1输出YES,若fun返回0输出NO!。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数。不得增行或删行,也不得更改程序的结构!
给定源程序:
#include<stdio.h>
int fun(int m)
{ int k=2;
while(k<=m
else return 0;
}
main()
{ int n;
printf("/nPlease enter n:");
scanf("%d",
if(fun(n))printf("YES/n");
else printf("NO!/n");
}
填空题数据独立性分为逻辑独立性和物理独立性。当总体逻辑结构改变时,其局部逻辑结构可以不变,从而根据局部逻辑结构编写的应用程序不必修改,称为U [3] /U。
填空题下列给定程序的功能是:建立一个带头结点的单向链表,并用随机函数为各结点数据域赋值。函数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,"/nTHE LIST:/n/n HEAD");
while(p)
{
fprintf(pf,"->%d",p->data);
p=p->next;
}
fprintf(pf,"/n");
}
main()
{
NODE *head;
int m;
head=creatlink(12,100);
outlink(head,stdout);
m=fun(head);
printf("/nThe result:/n");
outresult(m,stdout);
}
填空题给定程序中,函数fun的功能是找出100~999之间(含100和999)所有整数中各位上数字之和为x(x为一正整数)的整数,然后输出;符合条件的整数个数作为函数值返回。
例如,当x值为5时,100~999之间各位上数字之和为5的整数有104、113、122、131、140、203、212、221、230、302、311、320、401、410、500。共有15个。当x值为27时,各位数字之和为27的整数是999。只有1个。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:源程序存放在考生文件夹下的BLANK1.C中。
不得增行或删行,也不得更改程序的结构!
给定源程序如下。
#include<stdio.h>
int fun(int x)
{ int n,s1,s2,s3,t;
n=0;
t=100;
/************found***********/
while(t<=______){
/************found***********/
s1=t%10;s2=(______)%10;s3=t/100;
/*************found*********/
if(s1+s2+s3==______)
{ printf("%d",t);
n++;
}
t++;
}
return n;
}
main()
{ int x=-1;
while(x<0)
{printf("Please input(x>0):");
scanf("%d",}
printf("/nThe result is:%d/n",fun(x));
}
