填空题以下程序的输出结果是______。 #inciude<stdio.h> main() char s[]="ABCabc"; s[5]='/0'; printf("%s/n",s);
填空题下列给定程序中,函数fun()的功能是:将长整型数中各位上为奇数的数依次取出,构成一个新数放在t中。高位仍在高位,低位仍在低位。
例如,当s中的数为87653142时,t中的数为7531。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
void fun(long s,long*t)
{
int d;
long s1=1;
//****found****
t=0;
while(s>0)
{
d=s%10;
//****found****
if(d%2==0)
{
*t=d*s1+*t;
s1*=10;
}
s/=10;
}
}
void main()
{
long s,t;
system("CLS");
printf("/nPlease enter s:");
scanf("%id",
fun(s,
printf("The result is:%id/n",t);
}
填空题有以下程序
main( )
{ int n=0,m=1,x=2;
if(!n) x-=1;
if(m) x-=2;
if(x) x-=3;
printf(“%d/n”,x);}
执行后输出结果是 {{U}} 【9】 {{/U}}。
填空题请补充函数fun(),该函数的功能是按条件删除一个字符串指定字符一半的数目,具体要求如下:如果该字符串所包含的指定字符的个数是奇数,则不予删除,如果其数目是偶数,则删除原串后半部分的指定字符。其中,a指向原字符串,删除后的字符串存放在b所指的数组中,c中存放指定的字符。 例如:当a输入“abababa”,c=‘a’时,b的输出为“ababb”; 如果a的输入为“ababa”,则b的输出为“ababa”。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。 试题程序: #include<stdio.h> #include<conio.h> #define LEN 80 void fun(char a[],char b[],char C) int i=0,j=0; int n=0; int m=0; while(a[i]!=‘/0’) if(a[i]==c) n++; i++; 【1】 ; if(n%2) while(a[j]!='/0') b[j]=a[j]; j++; b[j]='/0'; else while(a[i]!='/0') b[j++]=a[i]; if(a[i]==c) m++; if((m>n/2)&&(a[i]==c)) 【2】 ; i++; 【3】 ; main() char a[LEN],b[LEN]; char c; clrscr(); printf("Enter the string:/n"); gets(a); printf("Enter the character of the string deleted:"); scanf("%c",&c); fun(a,b,c); printf("The new string is:%s/n",b);
填空题若输入字符串:abcde,则以下while循环体将执行【8】次。while((ch=getchar())=='e')printf("*");
填空题下面程序的功能是建立一个有3个结点的单循环链表,然后求各个结点数值域data中数据的和,请填空。#include<stdio.h>#include<stdlib.h>structNODE{intdata;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{{U}}【19】{{/U}};printf("%d/n",sum);}
填空题以下程序用来统计文件中字符的个数。请填空。 #include“stadio.h” main() FILE *fp;long num=0L; if((fp=fopen(“fname.dat”,“r”))==NULL); printf(“0pen error/n”);exit(0); while( 【16】 ) fsetc(fp);num++; printf(“num=%1d/n”,num-1); fclose(fp);
填空题有以下程序: main() int a[]=1,2,3,4,S,6,7,8,9,0,*p; for(p=a;p<a+10;p++) printf("%d,",*p); 程序运行后的输出结果是______。
填空题下列程序的输出结果是______。 #include<stdio.h> int fun(int x) static int t=0; return(t+=x); main() int s,i; for(i=1;i<=5;i++)s=fun(i); printf("%d/n",s);
填空题下列给定程序中,函数fun的功能是:先从键盘上输入一个3行、3列的矩阵的各个元素的值,然后输出主对角线元素之和。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
void fun()
{
int a[3][3],sum;
int i,j;
/**********found**********/
sum=1;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
/**********found**********/
scanf("%d",a[i][j]);
}
fof(i=0;i<3;i++)
sum=sum+a[i][i];
printf("Sum=%d/n",sum);
}
void main()
{
fun();
}
填空题数据库理论中,数据的独立性一般可分为物理独立性和______。
填空题给定程序中,函数fun()的功能是计算下式直到,并把计算结果作为函数值返回。例如,若形参e的值为1e-3,函数的返回值为2.985678。#include<stdio.h>doublefun(doublee)inti;doubles,x;/**********found**********/s=0;i=(1);x=1.0;while(x>e)/**********found**********/(2);/**********found**********/x=(2.0*i-1)/((3)*(2.0*i));s=s+x;returns;main()doublee=1e-3;printf("/nTheresultis:%f/n",fun(e));
填空题下列给定程序中,函数proc()的功能是:对M名学生的学习成绩,按从低到高的顺序找出m(m≤10)名学生来,并将这些学生数据存放在一个动态分配的连续存储区中,此存储区的首地址作为函数值返回。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<stdlib.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
#include<malloc.h>
#define M 10
typedef struct ss
{
char num[10];
int s;
}STU;
STU*proc(STU a[],int m)
{
STU b[M],*t;
int i,j,k;
//****found****
*t=calloc(m,sizeof(STU));
for(i=0;i<M;i++)
b[i]=a[i];
for(k=0;k<m;k++)
{
for(i=j=0;i<M;i++)
if(b[i].s<b[j].s)j=i;
//****found****
t[k].num=b[j].num;
t[k].s=b[j].s;
h[j].s=100;
}
return t;
}
void outresult(STU a[],FILE*pf)
{
int i;
for(i=0;i<M;i++)
fprintf(pf,"No=%s Mark=%d/n",
a[i].num,a[i].s);
fprintf(pf,"/n/n");
}
void main()
{ STU stu[M]={{"A01",81},{"A02",89},
{"A03",66},{"A04",87},
{"A05",77},{"A06",90},
{"A07",79},{"A08",61},
{"A09",80},{"A10",71}};
STU *pOrder;
int i.m;
system("CLS");
printf("****THE RESULT****/n");
outresult(stu,stdout);
printf("/nGive the number of the students who have
lower score:");
scanf("%d",
}
while(m>10)
{
printf("/nGive the number of the students who have
lower score:");
scanf("%d",
}
pOrder=proc(stu,m);
printf("****THE RESULT****/n");
printf("The top:/n");
for(i=0;i<m;i++)
printf("%s%d/n",pOrder[i].num,pOrder[i].s);
free(pOrder);
填空题给定程序中,函数fun的功能是:将形参指针所指结构体数组中的3个元素按num成员进行升序排列。请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。注意:部分源程序给出如下。不得增行或删行,也不得更改程序的结构!试题程序:
填空题若已知a=10、b=20,则表达式! a<b的值为 【6】 。
填空题设有以下定义 stuctss { intinfo;structss*link;}x,y,z; 且已建立如下图所示链表结构: 请写出删除结点y的赋值语句________。
填空题下列给定程序中,函数fun的功能是:根据形参m的值(2≤m≤9),在m行m列的二维数组中存放如下所示规律的数据,由main函数输出。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<conio.h>
#include<stdio.h>
#define M 10
int a[M][M]={0};
/*********found*********/
void fun(int**a,int m)
{int j,k;
for(j=0;j<m;j++)
for(k=0;k<m;k++)
/*********found*********/
a[j][k]=k*j;
}
main()
{int i,j,n;
printf("Enter n:");
scanf("%d",
fun(a,n);
for(i=0;i<n;i++)
{for(j=0;j<n;j++)
printf("%4d",a[i][j]);
printf("/n");
}
}
填空题下面程序的功能:输出100以内能被3整除且个位数为6的所有整数,请填空。
# include<stdio. h>
main()
{ int i, j;
for(i=0; i<10或i<=9; i++)
{ j=i*10+6;
if({{U}} 【15】 {{/U}})continue;
printf("% d", j);
}
}
填空题按照逻辑结构分类,数据结构可分为线性结构和非线性结构,二叉树属于______。
填空题函数fun的功能是进行字母转换。若形参ch中是小写英文字母,则转换成对应的大写英文字母:若ch中是大写英文字母,则转换成对应的小写英文字母;若是其他字符,则保持不变,并将转换后的结果作为函数值返回。
请在程序的下划线处填入正确的内容,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
#include<ctype.h>
char fun(char ch)
{
/**********found**********/
if((ch>="a")______(ch<="z"))
return(ch-"a"+"A");
if(isupper(ch))
/**********found**********/
return ch+"a"-______;
/**********found**********/
return______;
}
main()
{char c1,c2;
printf("/nThe result:/n");
c1="w";c2=fun(c1);
printf("c1=%c c2=%c",c1,c2);
c1="w";c2=fun(c1);
printf("c1=%c c2=%c",c1,c2);
c1="8";c2=fun(c1);
printf("c1=%c c2=%c",c1,c2);
}
