填空题以下程序段的运行结果是______。 #include<stdio.h> main() int x=2,y=1: switch(x) case 1: switch(y) case 0:printf("x=2,y=1/n");break; case 1:printf("y=1/n");break; case 2:printf("x=2/n");
填空题若a是int型变量,则下列表达式的值为______。 (a=2*3,a*2) ,a+4
填空题给定程序中,函数fun的功能是:将形参std所指结构体数组中年龄最大者的数据作为函数值返回,并在main函数中输出。 请在程序的下画线处填入正确的内容,并把下画线删除,使程序得出正确的结果。 [注意] 部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在fun函数的横线上填入所编写的若干表达式或语句。 [试题源程序] #include<stdio.h> typedef struct char name[10]; int age; )STD; STD fun(STD std[], int n) STD max; int i; /**********found**********/ max= (1) ; for(i=1; i<n; i++) /**********found**********/ if(max.age< (2) ) max=std[i]; return max; main() STD std[5]="aaa", 17, "bbb", 16, "ccc", 18, "ddd", 17, "eee", 15; STD max; max=fun(std, 5); printf("/nThe result: /n"); /**********found**********/ printf("/nName: %s, Age: %d/n", (3) , max.age);
填空题以下程序运行后的输出结果是{{U}} {{/U}}。#include <stdio, h>main( ) char c1 ,c2; for( el =' 0', c2 ='9'; e1<c2; c1 + + , c2 -- ) printf(" %c%c", c1, c2 ); printf("//n" );
填空题请补充main()函数,该函数的功能是:把一个二维字符数组每行字符串中最大的字符复制到字符数组s中。 例如,如果arr[3]="hoih", "yufui", "xgf",则str="oyx"。 注意:部分源程序已给出。 请勿改动主函数main和其他函数中的任何内容。 试题程序: #include<stdlib.h> #include<stdio.h> void main() int i=0; char *arr[3]="hoih", "yufui", "xgf"; char **p; char str[8]; system("CLS"); (1) ; for(i=0; i<3; i++) str[i]= *p[i]; while(* p[i]) if (str[i]<*p[i]) str[i]=*p[i]; (2) ; (3) ; printf("new string/n"); puts(str);
填空题下列程序舶输出结果是{{U}} 【12】 {{/U}}。
#include <stdio.h>
main()
{
int a[5]={2,4,6,8,10},*p;
p=a;p++;
printf("%d",*p);
}
填空题函数mystrlen(char *s)的功能是求字符串s的长度,请填空。 mystrlen(char *s) char *t: t=s; while(______)t++; return(t-s);
填空题以下程序运行后的输出结果是{{U}} {{U}} {{/U}} {{/U}}。
fun(int a)
{ int b=0;static int c=3;
b++;c++;
return(a+b+c) ;
}
main()
{ int i,a=5;
for(i=0;i<3;i++)printf("%d%d",i,fun(a) );
prind("/n");
}
填空题若有如下定义,则该数组的第一维大小为 【8】 。 int b[][4]=1,2,3,4,5,6,7,8,9);
填空题请补充函数fun(),该函数的功能是:依次取出字符串中所有的小写字母以形成新的字符串,并取代原字符串。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。 试题程序: #include<stdio.h> #include<conio.h> void fun(char *s) int i=0; char *p=s; while( 【1】 ) if (*p>='a' 【2】 ; p++; s[i]= 【3】 ; main() char str[80]; clrscr(); printf("/nEnter a string:"); gets(str); printf("/n/nThe string is:/%s/n",str); fun(str); printf("/n/nThe string of changing is:/%s/n",str);
填空题定义int a=5,b;,则执行表达式b=++a*--a之后,变量b的值为 【8】 。
填空题若有如下定义:
int[]={11,24,56,19,29,39),*t=s;
则不移动指针t,且通过指针t引用数组中值为29的元素的表达式是{{U}} 【7】 {{/U}}。
填空题下面程序的功能是:将字符数组a中下标值为偶数的元素从小到大排列,其他元素不变。请填空。
#include<stdio.h>
#include<string.h>
main()
{ char a[]="clanguage",t;
int i,j,k;
k=strlen(a);
for(i=0;i<=k-2;i+=2)
for(j=i+2;j<=k;j+=2;)
if(_______)
{t=a[i];a[i]=a[j];a[j]=t;}
puts(a);printf("/n");
}
填空题测试用例包括输入值集和 【1】 值集。
填空题给定程序的功能是:从键盘输入若干行文本(每行不超过80个字符),写到文件myfile4. txt中,用-1作为字符串输入结束的标志。然后将文件的内容读出显示在屏幕上。文件的读写分别由自定义函数ReadText和WriteText实现。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:源程序存放在
下的BLANK1. C中。不得增行或删行,也不得更改程序的结构!
#include <stdio. h>
#include <string. h>
#include <stdlib. h>
void WriteText(FILE *);
void ReadText(FILE *);
main( )
{FILE *fp;
if((fp=fopen("myfile4. txt", "w"))
==NULL)
{printf("open fail!!/n");
exit(0);}
WriteText(fp);
fclose(fp);
if((fp=fopen("myfile4. txt",
"r"))==NULL)
{printf("open fail!!/n");
exit(0);}
ReadText(fp);
fclose(fp);
}
/**********found**********/
void WriteText(FILE ______)
{ char str[81];
printf ("/nEnter string with -1 to end:/n");
gets(str);
while(strcmp(str, "-1")!=0) {
/**********found**********/
fputs(______, fw);
fputs("/n", fw);
gets(str);
}
}
void ReadText(FILE *fr)
{char str[81];
printf("/nRead file and output to screen:/n");
fgets(str, 81, fr);
while(!feof(fr)) {
/**********found**********/
printf("%s", ______);
fgets(str, 81, fr);
}
}
填空题下列给定程序中,函数fun的功能是:在形参ss所指字符串数组中查找与形参t所指字符串相同的串,找到后返回该串在字符串数组中的位置(即下标值),若未找到则返回-1。ss所指字符串数组中共有N个内容不同的字符串,且串长小于M。
请在下画线处填入正确的内容并将下画线删除,使程序得出正确的结果。
注意:部分源程序在文件BLANK1.C中。
不得增行或删行,也不得更改程序的结构!
#nclude <stdio.h>
#include <string.h>
#define N 5
#define M 8
int fun(char(**ss)[M],char*t)
{ int i;
/* * * * * * * * * *found* * * * * * * * * *
for(i=0;i<______;i++)
/* * * * * * * * * *found* * * * * * * * * *
if(strcmp(ss[i],t)==0) return ______;
return-1;
}
main( )
{char ch[N][M]={"if","while","switch","int","for"},t[M];
int n,i;
printf("/nThe original string/n/n");
for(i=0;i<N;i+ +) puts(ch[i]);
printf("/n");
printf("/nEnter a string for search:");gets(t);
n=fun(ch,t);
/* * * * * * * * * *found* * * * * * * * * *
if(n==______)printf("/nDon"t found!/n");
else printf("/nThe position is %d./n".n);
}
填空题下列给定程序中,函数fun的功能是:在形参ss所指字符串数组中,将所有串长超过k的字符串中后面的字符删除,只保留前面的k个字符。ss所指字符串数组中共有N个字符串,且串长小于M。
请在下划线处填入正确的内容并将下划线删除,使程序得出正确的结果。
注意
:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include <stdio.h>
#include <string.h>
#define N 5
#define M 10
/********found********/
void fun(char (*ss) ______,int k)
{int i=0;
/********found********/
while(i<______){
/********found********/
ss[i][k]=______;i++;}
}
main()
{char x[N][M]={"Create","Modify","Sort","skip","Delete"};
int i;
printf("/nThe original string/n/n");
for(i=0;i<N;i++)puts(x[i]);
printf("/n");
fun(x,4);
printf("/nThe string after deleted:/n/n");
for(i=0;i<N;i++)puts(x[i]);
printf("/n");
}
填空题下列给定程序中,函数fun()的功能是将字符串s中位于偶数位置的字符或ASCII码为奇数的字符放入字符串t中(规定第一个字符放在第0位中)。
例如:字符串中的数据为ADFESHDI,则输出应当是 AFESDI。
请改正程序中的错误,使它能得到正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <conio.h>
#include <stdio.h>
#include <string.h>
#define N 80
/************found*************/
void fun(char s,char t[])
{
int i,j=0;
for(i=0;i<strlen(s);i++)
/*********found*+************/
if(i%2=0 || s[i]%2!=0)
t[j++]=s[i];
t[j]='/0';
}
main()
{
char s[N],t[N];
clrscr();
printf("/nPlease enter string s:");
gets(s);
fun(s,t);
printf("/nThe result is:%s/n",t);
}
填空题下列程序中的函数stropy2()实现字符串两次复制,即将t所指字符串复制两次到s所指内存空间中,合并形成一个新字符串。例如,若t所指字符串为:efgh,调用strcpy2后,s所指字符串为:efghefgh。请填空。
#include <stdio.h>
#include <string.h>
void strcpy2(char *s,char *t)
{ char *p=t;
while(*s++=*t++);
s={{U}} 【15】 {{/U}};
while({{U}} 【16】 {{/U}}=*p++);
}
main()
{ char str1[100]="abed",str2[]="efgh";
strcpy2(str1,str2); printf("%s/n",str1);
}
填空题fun函数的功能是:首先对a所指的N行N列的矩阵,找出各行中的最大的数,再求这N个最大值中的最小的那个数作为函数值返回。请填空。#include <stdio. h>#define N 100int fun(int(*a)[N]) int row, col, max, min; for(row=0;row<N;row++ for(max=a[row][0],col=1;col<N;col++) if( 【13】 )max=a[row][col]; if (row==0)min=max; else if ( 【14】 )min=max; return min;
