填空题若要使指针p指向一个double类型的动态存储单元,请填空。 p= 【11】 malloc(sizeof(double));
填空题在内存中,存储字符'x'要占用1个字节,存储字符串"X"要占用 【11】 个字节。
填空题下列程序段中循环体的执行次数是______;
a=15;
b=0;
do{b+=2;a-=2+b;}while(a>=0);
填空题给定程序中,函数fun的功能是将带头结点的单向链表逆置。即若原链表中从头至尾结点数据域依次为:2、4、6、8、10,逆置后,从头至尾结点数据域依次为:10、8、6、4、2。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
不得增行或删行,也不得更改程序的结构!
给定源程序:
#include<stdio.h>
#include<stdlib.h>
#define N 5
typedef struct node{
int data;
struct node *next;
}NODE;
void fun(NODE *h)
{NODE *p,*q,*r;
/**********found**********/
p=h->______;
/**********found**********/
if(p==______)return;
q=p->next;
p->next=NULL;
while(q)
{r=q->next;q->next=p;
/**********found**********/
p=q;q=______;
}
h->next=p;
}
NODE*creatlist(int a[])
{NODE*h,*p,*q;int i;
h=(NODE*)malloc(sizeof(NODE));
h->next=NULL;
for(i=0;i<N;i++)
{q=(NODE*)malloc(sizeof(NODE));
q->data=a[i];
q->next=NULL;
if(h->next==NULL)h->next=p=q;
else{p->next=q;p=q;}
}
return h;
}
void outlist(NODE *h)
{NODE *p;
p=h->next;
if(p==NULL)printf("The list is NULL!/n");
else
{printf("/nHead");
do
{printf("->%d",p->data);p=p->next;
}
while(p!=NULL);
printf("->End/n");
}
}
main()
{NODE*head;
int a[N]={2,4,6,8,10};
head=creatlist(a);
printf("/nThe original list:/n");
outlist(head);
fun(head);
printf("/nThe list after inverting:/n");
outlist(head);
}
填空题有以下程序: main() int a[]=1, 2, 3, 4, 5, 6, 7, 8, 9, 0, *p; for(p=a; p<a+10; p++)printf("% d,", *p); 程序运行后的输出结果是 【10】 。
填空题若有定义:int a=10,b=8,c=4;然后顺序执行下列语句后,变量a中的值是______。 c=(b-=(a-4));a=(c%2)+(b-1);
填空题下面程序的功能是建立一个有3个结点的单循环链表,如下图所示然后求各个结点数值域data中数据的和,请填空。#include<stdio.h>#includestructNODEintdata;structNODE*next;;main()structNODE*p,*q,*r;intsum=0;p=(structNODE*)malloc(sizeof(structNODE));q=(structNODE*)malloc(sizeof(structNODE));r=(structNODE*)malloc(sizeof(structNODE));p->data=100;q->data=200;r->data=300;p->next=q;q->next=r;r->next=p;sum=p->data+p->next->data+r->next->next______;printf("%d/n",sum);
填空题下面程序的功能是{{U}} 【12】 {{/U}}。
double sub(double x,int y)
{int n; double z;
for(n=1,z=x;n<y;n++) z=z* x;
return z; }
main()
{double a=2.0,b=4.0,c;
c=sub(a,b) ; printf("%f",c) ; }
填空题下述函数通过递归方法将字符串倒置,使用时需要指定字符数组的首地址、起始下标和终止下标。请填空: #include<stdio.h> void fun(char *s,int low,int high) if( 【12】 ) return; else char t; fun( 【13】 ); t=s[low]; s[low]=s[high]; s[high]=t;
填空题下列程序的输出结果是 【6】 main( ) int a=1,b=2; a= a + b;b=a-b;a=a-b; printf("%d,%d/n",a,b);
填空题以下程序的输出结果是{{U}} {{U}} {{/U}} {{/U}}。
#include <stdio.h>
#define M 5
#define N M+M
main0
{ int k;
k = N'N*5; printf("%d/n",k);
}
填空题以下程序的功能是:通过函数func输入字符并统计输入字符的个数。输入时用字符@作为输入结束标志。请填空。
#include <stdio.h>
long{{U}} 【14】 {{/U}}; /*函数说明语句*/
main()
{ long n;
n=func(); printf("n=%1d/n"n);
}
long func()
{ long m;
for( m=0;getchar()!=@{{U}} 【15】 {{/U}};
return m;
}
填空题以下程序运行时若从键盘输入:10 20 30<回车>,输出结果是{{U}} {{/U}}。 # include<stdio.h> main() int i=0,j=0,k=0; scanf("%d% *d%d",printf("%d %d %d//n",i,j,k);
填空题表达式pow(2.8,sqrt(float(x)))值的数据类型为______型。
填空题设有下列程序:#include<stdio.h>#include<string.h>main() int i; char s[10],t[10]; gets(t); for(i=0;i<2;i++) gets(s); if(strcmp(t,s)<0)strcpy(t,s); printf("%s/n",t); 程序运行后,从键盘上输入(<CR>代表回车符):DEF<CR>BADEF<CR>QTHRG<CR>,则程序的输出结果是______。
填空题一个项目具有一个项目主管,一个项目主管可管理多个项目,则实体“项目主管”与实体“项目”的联系属于{{U}} 【3】 {{/U}}的联系。
填空题下列程序执行后输出的结果是{{U}} 【9】 {{/U}}。
f(int a)
{ static c=0;
c=a+c++;
return(c);
}
main()
{ int a=2,i,k;
for(i=0;i<2;i++)
k=f(a++);
prinf("%d/n",k);
}
填空题下述函数用于统计一行字符中的单词个数,单词之间用空格分隔。 word num (str) char str[]; int i,num=0,word=0; for(i=0;str[i]!= 【15】 ;i++) if( 【16】 ==)word=0; else if(word==0) word=1; 【17】 ; return(num);
填空题有以下程序: #include<stdio.h> main() int f,f1,f2,i; f1=0;f2=1 printf("%d%d",f1,f2); for(i=3;i<=5;i++) f=f1+f2;printf("%d",f); f1=f9;f2=f; printf("/n"); 程序运行后的输出结果是______。
填空题请补充函数fun(),该函数的功能是判断一个数是否为回文数。当字符串是回文时,函数返回字符申:yes!,否则函数返回字符串:no!,并在主函数中输出。所谓回文即正向与反向的拼写都一样,例如:abcba。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。 试题程序: #include<string.h> #include<stdio.h> char *fun(char*str) char *p1,*p2; int i, t=0; p1=str;p2=str+strlen(str)-1; for (i=0; 【1】 ;i++) if( 【2】 ) t=1; break; if ( 【3】 ) return("yes!"); else return("no!"); main() char str[50]; printf("Input;"); scanf("%s",str); printf("%s/n",fun(str));
