填空题“printf("%d/n",strlen("/t/"/023/xAB/nC"));”语句的输出结果是______。
填空题在对文件进行操作的过程中,若要求文件的位置回到文件的开头,应当调用的函数是{{U}} 【17】 {{/U}}函数。
填空题下列给定程序中函数fun()的功能是:把从主函数中输入的3个数,最大的数放在a中,中间的数放在b中,最小的数放在c中。
例如,若输入的数为:55,12,34,输出的结果应当是:a=55.0,b=34.0,c=12.0。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
void fun(float*a,float*b,float*c)
{
//****found****
float*k;
if(*a<*b)
{
k=*a;
*a=*b;
*b=k;
}
//****ound****
if(*a>*c)
{
k=*c;
*c=*a;
*a=k;
}
if(*b<*c)
{
k=*b;
*b=*c;
*c=k;
}
}
void main()
{
float a,b,c;
printf("Input a b c:");
scanf("%f%f%f",
printf("a=%4.1f,b=%4.1f,c=%4.1f/n/n",a,b,c);
fun(
printf("a=%4.1f,b=%4.1f,c=%4.1f/n/n"a,b,c);
}
填空题以下程序中函数f的功能是在数组x的n个数(假定n个数互不相同)中找出最大最小数,将其中最小的数与第一个数对换,把最大的数与最后一个数对换。请填空。
# include <stdio.h>
void f(int x[], int n)
{ int p0, p1, i,j,t,m;
i=j=x[O]; p0=p1=O;
for(m=0;m<n;m++)
{ if( x[m]>i ) { i=x[m]; p0=m; }
else if(x[m]<j) {j=x[m]; p1=m;}
}
t=x[p0]; x[p0]=x[n-1]; x[n-1]=t;
t=x[p1]; x[p1]={{U}} 【14】 {{/U}};{{U}} 【15】 {{/U}}=t;
}
main()
{ int a[10], u;
for(u=O;u<10;u++) scanf("%d",
f(a, 10);
for(u=O;u<10;u++) printf(" %d", a[u]);
printf("/n");
}
填空题下列程序的运行结果为 【4】 。 #include <stdio.h> main() static char str1[40]; char str2140]; strcpy(str2,"China"); strcat(str1,str2); strcat(str1," is a great country !"); printf("%s %s ",str2,strl); printf("%d %d/n",strlen(str2),strlen(str1));
填空题计算机中存储容量的基本单位是字节,它的英文名称是{{U}} 【1】{{/U}}。
填空题请补充函数proc(),该函数的功能是:把字符串str中的字符按字符的ASCII码升序排列,处理后的字符串仍然保存在原串中,字符串及其长度作为函数参数传入。
例如,如果输入“gfedcba”,则输出为“abcdefg”。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<stdlib.h>
#define N 80
void proc(char str[],int n)
{
int i,j;
char ch;
for(i=0;i<n;i++)
for(j=______;j<n;j++)
if(str[i]>str[j])
{
ch=str[j];
______;
str[i]=ch;
}
}
void main()
{
int i=0,strlen=0;
char str[N];
system("CLS");
printf("/nInput a string:/n");
gets(str);
while(str[i]!="/0")
{
strlen++;
i++;
}
proc(str,strlen);
printf("/n***display string***/n");
puts(str);
}
填空题下面的程序可对指定字符串中的字符串进行从大到小排序,请将程序完整。 (注:程序采用了冒泡排序算法) #include<stdio.h> #include<string.h> main() char*str="ABCDabcd",temp; int n,i; n=strlen(str); while(n->1) for(i=0;i<n;i++) if(str[i]<str[i+1]) temp= 【17】 ; str[i]=str[i+1]; 【18】 =temp; printf( 【19】 );
填空题给定程序MODI1.C中函数fun的功能是:从N个字符串中找出最长的那个串,并将其地址作为函数值返回。各字符串在主函数中输入,并放入一个字符串数组中。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 文件MODI1.C内容如下: #include<stdio.h> #include<string.h> #define N 5 #define M 81 /**********found**********/ fun(char(*sq)[M]) int i; char *sp; sp=sq[0]; for(i=0;i<N;i++) if(strlen(sp)<strlen(sq[i]))sp=sq[i]; /**********found**********/ return sq; void main( ) char str[N][M],*longest; int i; printf("Enter%d lines: /n",N); for(i=0;i<N;i++)gets(str[i]); printf("/nThe N string: /n",N); for(i=0;i<N;i++)puts(sir[i]); longest=fun(str); printf("/nThe longest string: /n"); puts(longest);
填空题以下程序的输出结果是______。 void fun( ) static int a=0; a+=2;printf("%d",a); main( ) int cc; for(cc=1;cc<4;cc++)fun( ); printf("/n");
填空题以下程序中函数f的功能是在数组x的n个数(假定n个数互不相同)中找出最大最小数,将其中最小的数与第一个数对换,把最大的数与最后一个数对换。请填空。 #include <stdio.h> voidf(int x[],int n) int p0,p1,i,j,t,m; i=j=x[0]; p0=p1=0; for(m=0;m<n;m++) if(x[m]>i i=x[m];p0=m; else if(x[m]<j j=x[m];p1:m; t=x[p0];x[p0]=x[n-1];x[n-1)=t t=x[p1];x[p1]= [12] ; [13] =t; main() int a[10],u; for(u=0;u<10;u++) scanf("%d",&a[u]); f(a,10); for(u=0;u<10;u++) printf("%d",a[u]); printf("/n");
填空题下列程序运行时,若输入1abcdef2df<回车>,输出结果为______。 #include<stdio.h> main() char a=0,ch; while((ch=getchar())!='/n') if(a%2!=0&&(ch>='a'&&ch<='z'))ch=ch-'a'+'A': a++;putchar(ch); printf("/n");
填空题设有说明; struct DATE int year; int month; int day;; 请写出一条定义语句,该语句定义d为上述结构体类型变量,并同时为其成员year、month、day依次赋初值2006、10、1: 【19】 。
填空题若想通过以下输入语句使a中存放字符串1234,b中存放字符5,则输入数据的形式应该是______。 char a[10],b; scanf("a=%s b=%c",a,&b);
填空题请补充函数proc(),该函数的功能是:从“a”到“z”统计一个字符串中所有字母字符各自出现的次数,结果保存在数组buff中。注意:不区分大小写,不能使用字符串库函数。
例如,若输入:“A=abc+5*c”,则输出结果为:a=2 b=1 c=2,d以后所有字母字符出现的次数全为0。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
#define M 100
void proc(char *str, int buff[])
{
int i;
char *p=str;
for(i=0; i<26; i++)
______;
while(*p)
{
if(*p>="A"
if(*p>="a"
______;
}
}
void main()
{
char str[M];
char a="a";
int buff[26], k;
system("CLS");
printf("/nPlease enter a char string: ");
scanf("%s", str);
printf("/n**The original string**/n");
puts(str);
proc(str, buff);
printf("/n**The number of letter**/n");
for(k=0; k<26; k++)
{
if(k%5==0)
printf("/n");
printf("%c=%d", a+k, buff[k]);
}
printf("/n");
}
填空题下列程序的运行结果为 【4】 。 enum weekday sun=7,mon=1,tue,wed, thu, fri,sat; main ( ) enum weekday workday,week end; int i,a[8]; workday=tue; week end=sun; printf ("/ntueday=%d sunday=%d; ",workday, week_end); workday=sun+tue; week_end= (enum weekday)3; printf ("tueday=%d sunday=%d; ",workday, weekend); a [sun]=sun; a [mon]=mon; a [tue]=rue; a [wed]=wed; a [thu]=thu; a [fri]=fri; a [sat]=sat; for(i=l;i<=7;i++) printf("%d ",a[i]);
填空题以下程序运行时,若从键盘输入:10 20 30 <回车>,输出的结果是{{U}} 【6】 {{/U}}。
#include<stdio.h>
main()
{ int i=0,j=0,k=0;
scanf("% d%* d%d", &i,&j,&k);
prinff("%d%d%d/n",i,j,k);
}
填空题以下程序运行后的输出结果是 【12】 。 # define S(x) 4*x*x+1 main() int i=6,j=8; printf("%d/n",S(i+j));
填空题以下程序的输出结果是______。
main()
{ unsigned short a=65536;int b;
printf("%d/n",b=A) ;
}
填空题下列程序的字符串中各单词之间有一个空格,则程序的输出结果是______。
#include <string.h>
main()
{ char strl[]="How do you do", *p1=strl
strcpy(strl+strlen(strl)/2,"es she"):
printf("%s/n",p1):
}
