填空题若有如下结构体说明:
struct STRU
{int a,b;char c:double d;
struct STRU *p1,*p2;
};
请填空,以完成对t数组的定义,t数组的每个元素为该结构体类型。
{{U}} 【16】 {{/U}}t[20]
填空题程序的功能是将文件filel.c的内容输出到屏幕上并复制到文件file2.c中,请填空。 #include<stdio.h> main() FILE 【19】 ; fp1=fopen("filel.c","r"); fp2=fopen("file2.c","w"); while(!feof(fp1)) putchar(getc(fp1)); rewind(fp1); while(!feof(fp1)) putc( 【20】 ); fclose(fp1); fclose(fp2);
填空题若有语句 int i=-19,j=i%4; printf("%d/n", j), 则输出的结果是______。
填空题以下程序运行后的输出结果是【 】。
main( )
{ int x=15;
while(x>10 &&x<50)
{ x++;
if(x/3){ x++;break;}
else continue;
}
printf("%d\n",x);
}
填空题当执行以下程序段后,i的值是______、j的值是______、k的值是______。
int a, b, c, d, i, j, k;
a=10; b=c=d=5; i=j=k=0;
for(; a>b; ++b) i++;
while(a>++c) j++;
do k++; while(a>d++);
填空题下列给定程序中,函数fun()的功能是:对N名学生的学习成绩,按从低到高的顺序找出前m(m≤10)名学生来,并将这些学生数据存放在一个动态分配的连续存储区中,此存储区的首地址作为函数值返回。 请改正程序中的错误,使它能得到正确结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include <conio.h> #include <string.h> #include <stdio.h> #include <alloc.h> #define N 10 typedef struct SS char num[10]; int s; STU; STU *fun(STU a[],int m) STU b[N],*t; int i, j,k; /*************found*************/ *t=calloc(m,sizeof(STU)); for(i=0;i<N;i++) b[i]=a[i]; for(k=0;k<m;k++) /*************found*************/ for (i=j=0;i<N;j++) if(b[i].s<b[j],s) j=i; /*************found*************/ t[k].s=b[j].s; b[j].s=100; return t; outresult(STU a[],FILE *pf) int i; for(i=0;i<N;i++) fprintf(pf,"NO=%S Mark=%d/n", a[i].num,a[i].S); fprintf(pf,"/n/n"); main() STU a[N]="A01",77,"A02",85, "A03",96,"A04",65,"A05",75, "A06",96,"A07",76,"A08",63, "A09",69,"A10",78; STU *pOrder; int i,m; clrscr(); printf("*****THE RESULT*****/n"); outresult(a,stdout); printf("/nGive the number of the students who have lower score:"); scanf("%d",&m); while(m>10) printf("/nGive the number of the students who have lower score:"); scanf("%d",&m); pOrder=fun(a,m); printf("*****THE RESULT*****/n"); printf("The low:/n"); for(i=0;i<m;i++) printf("%s %d/n",porder[i].num, porder[i].s); free(porder);
填空题请补充函数proc(),该函数的功能是按条件删除一个字符串指定字符一半的数目,具体要求如下:如果该字符串所包含的指定字符的个数是奇数,则不删除,如果其数目是偶数,则删除原串后半部分的指定字符。其中,str指向原字符串,删除后的字符串存放在b所指的数组中,c中存放指定的字符。例如:当str输入“abcabcabcab”,c=b时,b的输出为“abcabcaca”;如果str的输入为“abcabcabca”,则b的输出为“abcabcabca”。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#define M 80
void proc(char str[], char b[], char c)
{
int i=0, j=0;
int n=0;
int m=0;
while(str[i]!="/0")
{
if(str[i]==c)
n++;
i++;
}
______;
if(n%2)
{
while(str[j]!="/0")
{
b[j]=str[j];
j++;
}
b[j]="/0";
}
else
{
while(str[i]!="/0")
{
b[j++]=str[i];
if(str[i]==c)
m++;
if((m>n/2)
i++;
}
______;
}
}
void main()
{
char str[M], b[M];
char c;
system("CLS");
printf("Enter the string: /n");
gets(str);
printf("Enter the character of the
string deleted: ");
scanf("%c",
proc(str, b, c);
printf("The new string is: %s/n", b);
}
填空题在Windows环境下,为了将屏幕内容存入剪贴板,应按【 】键。
填空题下列程序的输出结果是______。
#include<Stdio.h>
int fun(int x)
{ int p;
if(x==0‖x==1)
return 3;
else
p=x-fun(x-2);
return p;
}
void main()
{ printf("/n%d",fun(11));
}
填空题下列程序的输出结果是______。 main() int a=1,b=2,c=3,t=0; if(a<B) t=a;a=b;b=t; if(a<C) t=a;a=c;c=t; printf("%d,%d,%d/n",a,b,C) ;
填空题以下sum函数的功能是计算下列级数之和。 请给函数中的各变量正确赋初值。 double sum(doublex,intn) { int i; double a,b,s; ________ for(i=1;i<=n;i++= { a=a*x; b=b*i; s=s+a/b;} return s;=
填空题以下程序可把输入的十进制数以十六进制数的形式输出。
请在横线上填上适当的内容并把横线删除,使它能得出正确的结果。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<stdio.h>
void main()
{
char b[17]={"0123456789ABCDEF"};
int c[64],d,i=0,base=16;
long mum;
printf("Enter a number:/n");scanf("%1d",i++;num=num/base;}
while(num!=0);
printf("Transmite new base:/n");
for(--i:i2>=0:--i)
//****found****
{ d=c[i];printf("%c",b______);}
printf("/n");
}
填空题以下程序运行后的输出结果是 【17】 。#include <stdio.h>main ( ) char c;int n = 100; float f= 10:double x: x=f*=n/= (c=50); printf("% d% f/n",n,x);
填空题以下函数用来求出数组的最大元素在数组中的下标并存放在k所指的存储单元中。请填空。 #include<conio.h> #include<stdio.h> int fun(int%s, int t, int *k) int i; *k=0; (9) if(s[*k]<s[i])*k=i; return (10) ; main() int a[10]=876, 675, 896, 101, 301, 401, 980, 431, 451, 777, k; fun(a, 10, %k); printf("%d, %d/n", k, a[k]);
填空题从字符串s1中删除字符串s2所包含的字符。例如:s1为"helloword",s2为"eo",程序执行后,s1变为"hllwrd"。
#include<stdio.h>
int main()
{
char s1[81]="helloword", se[81]="eo";
char*p1=s1, *p2, *p3;
______;
while(*p1)
{
p2=s2;
while(*p2
if(*p2=="/0")
*p3++=*p1;
p1++;
}
______;
printf("%s/n", s1);
return 0;
}
填空题执行以下for语句后,变量i的值是 【6】 。 for(i=1;i++<=5;);
填空题以下程序的功能是 【18】 。 main( ) int num[10]=10,1,-20,-203,-21,2,-2,-2,11,-21; int sum=0,i; for(i=0;i<10;i+ +) if(num[i]>0) sum=num[i]+ sum; printf("sum=%6d",sum);
填空题以下程序运行后的输出结果是 [6] 。 main() char c;int n=100; float f=10;double x; x=f*=n/=(c=50); printf("%d %f/n",n,x);
填空题在线性表的多种存储结构中,最简单的方法是 【5】
填空题以下程序的运行结果是{{U}} {{/U}}。 # include<string.h> typedef struct student char name[10]; long sno); float score STU; main() STU a="zhangsan",2001,95,b="Shangxian",2002,90 c="Anhua",2003,95,d,*p= d=a; if(strcmp(a.name,b.name)>0)d=b; if(strcmp(c.name,d.name)>0)d=c; printf("%1d%s//n",d.sno,p->name);