填空题已有定义如下: struct node int data; struct node *next; *p; 以下语句调用malloc函数,使指针p指向一个具有struct node类型的动态存储空间。请填空。 p=(struct node *)malloc( 【19】 );
填空题以下程序段用于构成一个简单的单向链表。请填空。 struet STRU int x,y; float rate; 【14】 p; a,b; a.x=0; a.y=0;a.rate=0;a.p=&b; b.x=0;b.y=0;b.rate=0;b.p=NULL;
填空题以下程序运行后输入3,abcde<回车>,则输出结果是 【19】 。 #include<string.h> move (char *str,int n) char temp;int i; temp=str[n-1]; for(i=n-1;i>0;i--) str[i]=str[i-1]; str[0]=temp; main() char s[50]; int n,i,z; scanf("%d,%s", z=strlen(S); for(i=1;i<=n;i++) move(s,z); printf("%s/n",s);
填空题以下程序的输出结果是 【12】 。 #include <stdio.h> main() int a=1234; float b=123.456; double c=12345.54321; printf("/n%2d,%2.1f,%2.11f",a,b,C);
填空题有如下图所示的双链表结构,请根据图示完成结构体的定义:structaaintdata;【15】node;
填空题以下程序中函数fun的功能是:统计person所指结构体数组中所有性别(sex)为M的记录的个数,存入变量n中,并作为函数值返回。请填空。 #include #define N 3 typedef struct int num;char nam[10];char sex;SS; int fun(SS person[] int i,n=0; for(i=0;i<N;i++) if( [14] =='M')n++; return n;
填空题以下程序运行后的输出结果是 【15】 。#include <stdio.h>#include <string.h>char * ss(char * s) char * p,t; p=s+1:t= *s: whilet * p) *(,p-1) = *p; p++; * (p-1) =t; return s : main ( ) char * p,str[10] =" abedefgh"; p = ss(str); printf( "% s /n". p):
填空题若有如下程序:
#include"stdio.h"
main()
{char s[30];
strcpy(&s[0],"abc"); strcpy(&s[1],"de"); strcpy(&s[2],"f");
printf("%s/n",s); }
则程序运行后的输出结果是{{U}} 【7】 {{/U}}。
填空题下列给定程序中,函数fun()的功能是:根据输入的3个边长(整型值),判断能否构成三角形:若能构成等边三角形,则返回3,若是等腰三角形,则返回2,若能构成三角形则返回1,若不能,则返回0。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include <math. h> int fun(int a, int b, int c) if (a+b>c else if(a==b|| b==c||a==c) return 2; /*************found**************/ else return 3; else return 0; main ( ) int a,b, c, shape; printf("/nInput a,b,c: "); scanf ("%d%d%d", printf ("/na=%d, b=%d, c=%d/n",a,b,c); shape=fun (a,b, c); printf ("/n/nThe shape : %d/n", shape);
填空题给定程序中,函数fun的功能是:计算出带有头结点的单向链表中各结点数据域中值之和作为函数值返回。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
#include<stdio.h>
#include<stdlib.h>
#define N 8
typedef struct list
{int data;
struct list *next;
}SLIST;
SLIST*creatlist(int*);
void outlist(SLIST*);
int fun(SLIST*h)
{SLIST *p;int s=0;
p=h->next;
while(p)
{
/**********found**********/
s+=P->______;
/**********found**********/
p=p->______;
}
return s;
}
main()
{SLIST*head;
int a[N]={12,87,45,32,91,16,20,48};
head=creatlist(a);outlist(head);
/**********found**********/
printf("/nsum=%d/n",fun(______));
}
SLIST*creatlist(int a[])
{SLIST*h,*p,*q;int i;
h=p=(SLIST*)malloc(sizeof(SLIST));
for(i=0;i<N;i++)
{q=(SLIST*)malloc(sizeof(SLIST));
q->data=a[i];p->next=q;p=q;
}
P->next=0:
return h;
}
void outlist(SLIST*h)
{SLIST*p;
p=h->next;
if(p==NULL)printf("The list is NULL!/n");
else
{printf("/nHead");
do
{printf("->%dtt,p->data);p=p->next;}
while(p!=NULL);
printf("->End/n");
}
}
填空题请补充函数fun(),该函数的功能是:把一个整数转换成字符串,并倒序保存在字符数组str中。例如:当n=13572468时,str=-“86427531”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio.h>
#include <conio.h>
#define N 80
char str[N];
void fun(long int n)
{
int i=0;
while({{U}} {{U}} {{/U}}{{/U}})
{
str[i]={{U}} {{U}} {{/U}}{{/U}};
n/=10;
i++;
}
{{U}} {{U}} {{/U}}{{/U}};
}
main()
{
long int n=13572468;
clrscr();
printf("*** the origial data ***/n");
printf("n=%ld",n);
fun(n);
printf("/n%s",str);
}
填空题已知字符'A'的ASCII代码值为65,以下程序运行时若从键盘输入:B33 <回车>,则输出结果是{{U}} 【9】 {{/U}}。
#include <stdio.h>
main( )
{ char a,b;
a = getchar( ) ;seanf( "% d" ,
a=a-'A' +'0';b=b* 2;
prinff( "% c % c /n" ,a,b);
}
填空题假定变量x为int类型,请以最简单的形式写出与逻辑表达式!x等价的C语言关系表达式 【7】 。
填空题下列给定程序中,函数fun的功能是:计算如下公式直到,并且把计算结果作为函数值返回。例如,若形参e的值为le-3,则函数返回值为0.551690。请在下画线处填入正确的内容并将下画线删除,使程序得出正确的结果。注意:部分源程序给出如下。不得增行或删行,也不得更改程序的结构!试题程序:#include<stdio.h>doublefun(doublee){inti,k;doubles,t,x;s=0;k=1;i=2;/**********found**********/x=________/4;/**********found**********/while(x________e){s=s+k*x;k=k*(-1);t=2*i;/**********found**********/x=________/(t*t);i++;}returns;}main(){doublee=le-3;printf("/nTheresultis:%f/n",fun(e));}
填空题下面程序的运行结果是______。
#define DOUBLE(r)r*r
main()
{ int x=4,y=2,t;
t=DOUBLE(x+y);
printf("%d",t);
}
填空题以下程序运行后的输出结果是______。
#include<stdio.h>
main()
{ int a;
a=(int)((double)(3/2)+0.5+(int)1.99*2);
printf("%d/n", a);
}
填空题以下程序用于判断a、b、c能否构成三角形,若能,输出YES,否则输出NO。当给a、b、c输入三角形三条边长时,确定a、b、c能构成三角形的条件是需同时满足三个条件:a+b>c,a+c>b,b+c>a。 请填空。 main() float a,b,c; scanf("%f%f%f", if( 【7】 ) printf("YES/n"); /*a、b、c能构成三角形*/ else printf("NO/n"); /*a、b、c不能构成三角形*/
填空题以下程序运行后输出结果是{{U}} {{U}} {{/U}} {{/U}}。
#include <stdio, h>
main( )
{ int a,b,c;
a=10; b:20; c=(a%b<1) ‖ (a/b>1);
printf("%d %d %d/n",a,b,c);
}
填空题请补充main()函数,该函数的功能是求方程qx
2
+px+j=0的两个实数根。方程的系数q、p、j从键盘输入,如果判别式(disc=p
2
-4qj)小于0,则要求重新输入q、p、j的值。
例如,当q=1,p=-2,j=1时,方程的两个根分别是x1=1.00,x2=1.00。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在横线上填入所编写的若干表达式或语句。
试题程序:
#include<math.h>
#include<stdio.h>
#include<stdlib.h>
void main()
{
float q, p, j, disc, x1, x2;
system("CLS");
do
{
printf("Input q, p, j:");
scanf("%f, %f, %f",
disc=p*p-4*q*j;
if(disc<0)
printf("disc=%f/n Input again!/n", disc);
}
while(______);
printf("****the result****/n");
x1=______;
x2=______;
printf("/nx1=%6.2f/nx2=%6.2f/n", x1, x2);
}
填空题有以下程序
main( )
{ int n=0,m=1,x=2;
if(!n) x-=1;
if(m) x-=2;
if(x) x-=3;
printf(“%d\n”,x);}
执行后输出结果是【 】。
