填空题以下程序运行后的输出结果是{{U}} {{/U}}。 # include<string.h> void fun(char *s,int p,int k) int i; for(i=p;i<k-1;i++)s[i]=s[i+2]; main() char s[]="abcdefg"; fun(s,3,strlen(s));puts(s);
填空题下面程序的运行结果是______。
#define DOUBLE(x,y)x/y
main()
{ int x=4,y=2,t;
t=DOUBLE(x+y,x-y);
printf("%d",t);
}
填空题下面程序的功能是:计算1~20之间的奇数之和与偶数之和,请填空使程序功能完整。 #include<stdio.h> main() int a=0,b=0,c=0,i; for(i=0;i<=20;i+=2) a+=i; ______; c+=b; printf("偶数之和=%d/n",a); printf("奇数之和=%d/n",c-21);
填空题若a=1,b=2,c=3,d=4;则条件表达式a>b?a:c<d?c:d的结果为______。
填空题下列给定程序中,函数proc()的功能是:根据以下公式求π的值,并作为函数值返回。例如,给指定精度的变量eps输入0.0001时,应当输出Pi=3.141358。
π/2=1+i/3+1/3*2/5+1/3*2/5*3/7+1/3*2/5*3/7*4/9……
请修改程序中的错误,使它能得出正确的结果。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<conio.h>
#include<stdio.h>
#include<math.h>
double proc(double eps)
{ double s,t;int n=1;
s=0.0;
t=1;
//****found****
while(t>eps)
{ s+=t;
t=t*n/(2*n+1);
n++;
}
//****found****
return(s);
}
void main()
{ double s;
printf("/nPlease enter a precision:");
scanf("%1f",
printf("/nPi=%1f/n",proc(s));
}
填空题以下程序实现带有头结点的单链表的建立,链表中每个结点包含数据域data(字符型)和指针域next,所建立链表的头指针由参数phd传回调用程序。在空格处填入正确内容。
# include<stdio.h>
# include<stdlib, h>
struct node {
char data;
struct node * next;
};
void creatlist({{U}} 【18】 {{/U}})
{
char ch;
struct node * s, * r;
* phd= malloc( sizeof (struct node));
r= * phd;
ch=getchar();
while(ch !='@') {
s = malloc(sizeof(struct node));
s->data=ch;
r->next=s;
r=s;
ch= getchar();
};
r->next={{U}} 【19】 {{/U}};
}
main ( )
{
struct node * head;
head= NULL;
creatlist({{U}} 【20】 {{/U}})
}
填空题下列给定程序中函数fun()的功能是:求出字符串中最后一次出现的子字符串的地址,通过函数值返回,在主函数中输出从此地址开始的字符串;若未找到,则函数值为NULL。例如,当字符串中的内容为abcdabfabcdx,t中的内容为ab时,输出结果应是abcdx。当字符串中的内容为abcdabfabcdx,t中的内容为abd时,则程序输出未找到的信息:Not found!
请改正程序中的错误,使它能得出正确的结果。
注意;不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<stdio.h>
#include <conio.h>
#include <string.h>
char *fun(char *s,char *t)
{
char *p,*r,*a;
/*************found**************/
a=Null;
while(*s)
{ p=s;r=t;
while(*r)
/*************found**************/
if(r= =p) {r++;p++;}
else break;
if(*r=='/0') a=s;
s++;
}
return a;
}
main()
{char s[100],t[100],,*p;
clrscr();
printf("/nPlease enter string S: ");
scanf("%s",s);
printf("/nPlease enter substring t: ");
scanf("%s",t);
p=fun(S,t);
if(p) printf("/nThe result is:%s/n",p);
else printf("/nNot found!/n ");
}
填空题以下程序运行后的输出结果是{{U}} {{/U}}。 #include <stdio.h> fun(int x) if(x/2>0) fun(x/2); printf("%d",x); main() fun(6);
填空题诊断和改正程序中错误的工作通常称为______。
填空题设一棵二叉树的中序遍历结果为DBEAFC,前序遍历结果为ABDECF,则后序遍历结果为{{U}} 【4】 {{/U}}。
填空题有以下程序段: int a[l0]=1,2,3,4,5,6,7,8,9,10,*p= b=p[5]; b中的值是 【9】 。
填空题以下程序运行后的输出结果是{{U}} 【7】 {{/U}}。
main()
{ int a,b,c;
a=25;
b=025;
c=0x25;
printf("%d%d%d/n",a,b,c) ;
}
填空题以下程序的输出结果是{{U}} 【9】 {{/U}}。
#include <stdio.h>
main()
{ int j,a[]={1,3,5,7,9,11,13,15},*P=a+5;
for(j=3; j;j-)
{ switch(i)
{ case 1:
case 2: printf("%d",*p++); break;
case 3: printf("%d",* (-p));
}
}
}
填空题下面程序的功能是:将N行N列二维数组中每一行的元素进行排序,第0行从小到大排序,第1行从大到小排序,第2行从小到大排序,第3行从大到小排序,例如:请填空。#defineN4voidsort(inta[][N])inti,j,k,t;for(i=0;i<N;i++)for(j=0;j<N-1;j++)for(k=(11);k<N;K++)/*判断行下标是否为偶数来确定按升序或降序来排序*/if((12)?a[i][j]a[i][k])t=a[i][j];a[i][j]=a[i][k];a[i][k]=t;voidoutarr(inta[N][N])…main()inta[N][N]=2,3,4,1,8,6,5,7,11,12,10,9,15,14,16,13;outarr(aa);/*以矩阵的形式输出二维数组*/sour(aa);outarr(aa);
填空题下面程序的输出结果是 【15】 。 long fun5(int n) long s; if((n==1)||(n==2)) s=2; else s=n+fun5(n-1); return(s); main() long x; x=fun5(4); printf("%ld/n",x);
填空题请在以下程序第一行的下划线处填写适当内容,使程序能正确运行。
【 】( double,double);
main( )
{ double x,y;
scanf("%lf%lf",
printf("%lf/n",max(x,y));
}
double max(double a,double b)
{ return(a>b ? a:b); }
填空题关系表达式x<y<z,用C语言的表达式为{{U}} 【7】 {{/U}}。
填空题设x和y均为int型变量,且x=1,y=2,则表达式double(1+x/y)的值为 【12】 。
填空题下面程序执行后输出的结果是{{U}} 【8】 {{/U}}。
int m=13;
int fun(int x, int y)
{ int m=3;
return(x*y-m);
}
main()
{ int a=7,b=5;
printf("%d/n",fun(a,B) /m);
}
填空题以下程序的运行结果是{{U}} 【9】 {{/U}}。
main()
{ int a=2,b=7,c=5;
switch(a>0)
{ case 1:switch(b<0)
{ case 1:printf("@");break;
case 2:printf("!");break;
}
case 0:switch(c==5)
{ case 0:printf("*");break;
case 1:printf("#");break;
case 2:printf("$");break;
}
default:printf("&");
}
printf("/n");
}
