填空题数据结构包括数据的逻辑结构、数据的 【2】 以及列数据的操作运算。
填空题若整型变量a和b中的值分别为7和9,要求按以下格式输出a和b的值: a=7 b=9 请完成输出语句: printf("______",a,b);
填空题在C语言中,可以利用 【6】 ,将一个表达式的值转换成指定的类型。
填空题有以下语句段
int n1=10,n2=20; printf(“ {{U}} 【7】 {{/U}} ”,n1.n2);
要求按以下格式输出n1和n2的值,每个输出行从第一列开始,请填空。
n1=10 n2=20
填空题下列给定程序中,函数proc()的功能是找出100~m(m不大于1000)之间百位数字加十位数字等于个位数字的所有整数,把这些整数放在s所指的数组中,个数作为函数值返回。 请修改程序中的错误,使它能得到正确结果。 注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include<stdio.h> #define M 1000 int proc(int *s, int n) int i, j, k, a, b, c; j=0; for(i=100; i<n; i++) //************found************* k=n; a=k%10; k/=10; b=k%10; c=k/10; if(a==b+c) //************found************* s[j]=i; return j; void main() int a[M], m, num=0, i; do printf("/nEnter m(<=1000): "); scanf("%d", while(m>1000); num=proc(a, m); printf("/n/nThe result: /n"); for(i=0; i<num; i++) printf("%5d", a[i]); printf("/n/n");
填空题以下程序运行后的输出结果是 【12】 。 main() char a[]="123456789",*p; int i=0; p=a; while(*p) if(i%2==0) *p='*'; p++;i++; puts(A) ;
填空题以下程序运行后的输出结果是【 】。
main( )
{ int i,m=0,n=0,k=0;
for(i=9; i<=11;i++)
switch(i/10)
{ case 0: m++;n++;break;
case 10: n++; break;
default: k++;n++;
}
printf("%d %d %d/n",m,n,k);
}
填空题在E-R图中,______表示实体间的联系。
填空题以下程序的输出结果是 【17】 。 void fun() static int a; a+=2; printf("%d",a); main() int cc; for(cc=1;cc<=4;cc++)fun(); printf("/n");
填空题下列给定程序中,函数fun的功能是:统计带头结点的单向链表中结点的个数,并存放在形参n所指的存储单元中。
请在下划线处填入正确的内容并将下划线删除,使程序得出正确的结果。
注意
:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include <stdio.h>
#include <stdlib.h>
#define N 8
typedef struct list
{int data;
struct list *next;
}SLIST;
SLIST*creatlist(int *a);
void outlist(SLIST *);
void fun(SLIST *h, int *n)
{SLIST *p;
/********found********/
______=0;
p=h->next;
while(p)
{(*n)++;
/********found********/
p=p->______;
}
}
main()
{SLIST *head;
int a[N]={12,87,45,32,91,16,20,48}, num;
head=creatlist(a);
outlist(head);
/********found********/
fun(______,
printf("/nnumber=%d/n",num);
}
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("-%d",p->data);
p=p->next;}
while(p!=NULL);
prinft("->End/n");
}
}
填空题下列给定的程序中,函数fun()的功能是:判断字符ch是否与str所指字符串中的某个字符相同;若相同,则什么也不做,若相同,则将其插在申的最后。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <conio.h>
#include <stdio.h>
#include <string.h>
/*************found**************/
void fun (char str,char ch)
{while (*str
/*************found**************/
if(*str==ch)
{ str[0]=ch;
/*************found**************/
str[1]='0';
}
}
main()
{char s[81],c;
clrscr();
printf("/nPlease enter a strzng : ");
gets(s);
printf("/n Please enter the character to
search : ");
c=getchar();
fun(s,c);
printf("/nThe result is %s/n",s);
}
填空题以下程序的功能是调用函数fun计算:m=1-2+3-4+…+9-10,并输出结果。请填空。
int fun( int n)
{ int m=0,f=1,i;
for(i=1; i<=n; i++)
{ m+=i*f;
f={{U}} 【11】 {{/U}};
}
return m;
}
main( )
{ printf("m=%d/n",{{U}} 【12】 {{/U}} ); }
填空题以下程序的功能是建立一个带有头结点的单向链表,链表结点中的数据通过键盘输入,当输入数据为-1时,表示输入结束(链表头结点的data域不放数据,表空的条件是ph->next==NULL),请填空。 #include <stdio.h> struct list int data;struct list *next;; struct list *creatlist( ) struct list *p,*q,*ph;int a;ph=(struct list*)malloc(sizeof(struct list)); p=q=ph;printf("Input an integer number;entre-1 to end:/n"); scanf("%d",&a); while(a!=-1) p=(struct list*)malloc(sizeof(struct list)); [14] =a;q->next=p; [15] =p;scanf("%d",&a); p->next='/0';return(ph); main( ) stuct list * head;head=creatlist();
填空题从键盘输入一组小写字母,保存在字符数组str中。请补充函数proc(),该函数的功能是:把字符数组str中字符下标为奇数的小写字母转换成对应的大写字母,结果仍保存在原数组中。例如,输入abcdefg,输出aBcDeFg。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#define M 80
void proc(char str[])
{
int i=0;
while(______)
{
if(i%2!=0)
str[i]-=______;
______;
}
}
void main()
{
char str[M];
system("CLS");
printf("/n Input a string:/n");
gets(str);
printf("/n***original string***/n");
puts(str);
proc(str);
printf("/n***new string***/n");
puts(str);
}
填空题以下程序的输出结果是{{U}} 【18】 {{/U}}。
#include <stdio.h>
#define MAX(x,y)(x),(y)?(x):(y)
main()
{ int a=5,b=2,c=3,d=3,t;
t=MAX(a+b,c+d)*10;
printf("%d/n",t);
}
填空题以下程序给指针p分配三个double型动态内存单元,请填空。
#include <stdio.h>
#include <stdlib.h>
main()
{ double *p;
p=(double *)malloc({{U}} 【7】 {{/U}});
p[0]=1.5;p[1]=2.5;P[2]=3.5;
printf("%f%f%f/n",p[0],p[1],p[2]);
}
填空题以下说明语句中, 【13】 是结构体类型名。 typedef struct int n; char ch[8]; PER;
填空题以下程序运行后的输出结果是{{U}} 【7】 {{/U}}。
#include <stdio.h>
#define S(x) 4 * x * x + 1
main( )
{ int i=6,j=8;
prinff("% d / n" , S( i + j) );
}
填空题有以下程序:
main()
{char str[]="xyz", *ps=str;
while(* ps)ps++;
for(ps--; ps-str>=0;ps--)puts(ps);
}
执行后的输出结果是{{U}} 【3】 {{/U}}。
填空题以下程序中,fun函数的功能是求3行4列二维数组每行元素中的最大值,请填空void fun(int,int,int(*)[4],int *);main() int a[3][4]=12,41,36,28,19,33,15,27,3,27,19,1,b[3],i;fun(3,4,a,b);for(i=0;i<3;i++)printf("%4d",b[i]);printf("/n");void fun(int m,int n,int ar[][4],int *bar) int i,j,x;for(i=0;i<M;i++) x=ar[i][0]; for(j=0;j<N;j++) IF(X ______=x;