填空题以下程序运行后的输出结果是______。 main ( ) int a[4] ]4]=1,2,3,4,5,6,7,8,11,12,13,14,15,16,17,18; int i=0.j=0,s=0; while (i++<4 if (i == 2 || i == 4)continue; j =0; do s += a[i] [j]: j++; while (j<4); printf ( "%d/n", s); void fun(int x, int y)
填空题以下函数把b字符串连接到a字符串的后面,并返回a中新字符串的长度。请填空。 surcen(chara[],char b[]) int num=0,n=0; while(*(a+num)!=______)num++; while(b[n])*(a+num)=b[n];num++;______; return(num); _'/o'或0
填空题以下程序运行后的输出结果是{{U}} 【16】 {{/U}}。
struct NODE
{
int num;
stmct NODE *next;
};
main()
{struct NODE s[3]={{1,'/0'),{2,'/0'),{3,'/0'}),*p,*q,*r;
int sum=0;
s[0].next=s+1;
s[1].next=s+2;
s[2].next=s;
p=s
q=p->next;
r=q->next;
sum+=q->next->num;
sum+=r->next->next->num;
printf("%d/n",sum);
}
填空题请补充函数fun(),该函数的功能是:把从主函数中输入的字符串str2接在字符串str1的后面。 例如:str1=“How do”,str2=“you do?”,结果输出:How do you do? 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。 试题程序: #include<stdio.h> #include<conio.h> #define N 40 void fun(char *str1,char *str2) int i=0; char *p1=str1; char *p2=str2; while( 【1】 ) i++; for( ; 【2】 ;i++) *(p1+i)= 【3】 ; *(p1+i)='/0'; main() char str1[N],str2[N); clrscr(); printf("*****Input the string str1 & str2*****/n"); printf("/nstr1:"); gets(str1); printf("/nstr2:"); gets(str2); printf("**The string str1 & str2**/n"); puts(str1); puts(str2); fun(str1,str2); printf("*****The new string *****/n"); puts(str1);
填空题以下程序运行后的输出结果是{{U}} 【6】 {{/U}}。
#include <stdio.h>
int a=5;
fun (int b)
{ static int a=10;
a+ =b++;
printf("%d",a);
}
main()
{ int c=20;
fun(c);
a+ =c++;
printf("%d/n",a);
}
填空题条件“20<x<30或x<-100”的C语言表达式是 【10】 。
填空题在面向对象方法中 【1】 描述的是具有相似属性与操作的一组对象。
填空题以下程序运行后的输出结果是{{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));
}
}
}
