填空题请补充函数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);
}
填空题若想通过以下输入语句使a中存放字符串1234,b中存放字符5,则输入数据的形式应该是______。 char a[10],b; scanf("a=%s b=%c",a,&b);
填空题下列程序运行时,若输入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");
填空题计算机中存储容量的基本单位是字节,它的英文名称是{{U}} 【1】{{/U}}。
填空题以下程序运行时,若从键盘输入: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);
}
填空题给定程序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);
填空题下列程序的字符串中各单词之间有一个空格,则程序的输出结果是______。
#include <string.h>
main()
{ char strl[]="How do you do", *p1=strl
strcpy(strl+strlen(strl)/2,"es she"):
printf("%s/n",p1):
}
填空题设有说明; struct DATE int year; int month; int day;; 请写出一条定义语句,该语句定义d为上述结构体类型变量,并同时为其成员year、month、day依次赋初值2006、10、1: 【19】 。
填空题请补充函数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");
}
填空题以下程序运行后的输出结果是 【12】 。 # define S(x) 4*x*x+1 main() int i=6,j=8; printf("%d/n",S(i+j));
填空题以下程序中函数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");
填空题下列程序的运行结果为 【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]);
填空题以下程序的输出结果是______。
main()
{ unsigned short a=65536;int b;
printf("%d/n",b=A) ;
}
填空题下列给定程序中,fun()函数的功能是:根据形参m,计算下列公式的值。 t=-1+1/2+1/3+1/4+…+1/m 例如,若输入5,则应输出2.283333。 请改正程序中的错误,使它能计算出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include <conio.h> #include <stdio.h> double fun(int m) double t=1.0; int i; for(i=2;i<=m;i++) /*************found**************/ t+=1.0/k; /*************found**************/ return i; main() int m; clrscr(); printf("/nPlease enter linteger number:"); scanf("%d", printf("/nThe result is%1f/n", fun(m));
填空题以下程序是用递归方法求数组中的最大值及其下标值。请填空。
#define M 10
void findmax(int *a,int n,int i,int *pk)
{ if(i<n)
{ if(a[i]>a[ *pk]){{U}} 【15】 {{/U}};
findmax(a,n,i+1,i++)scanf("%d" ,a+i);
findmax(a,M,0,&n);
printf(" The maxinum is:%d/n" ,a[n]);
printf(" It's index is;%d/n" ,n);}
填空题以下程序段的输出结果是{{U}} 【6】 {{/U}}。
int i=9;
printf("%o/n",i);
填空题有序线性表能进行二分查找的前提是该线性表必须是【1】存储的。
填空题下列程序的输出结果是______。 main() int a=2,b=4,c=6; int*p1= *(p= printf("%d/n",c);
填空题以下程序的功能是:输出100以内(不含100)能被3整除且个位数为6的所有整数,请填空。 #include <stdio.h> main() int i,j for(i=0; 【15】 ;i++) j=i*10+6; if( 【16】 )continue: Printf("%d”",j);
填空题下列给定的程序中,函数proc()的功能是:计算并输出m以内最大的6个能被7或11整除的自然数之和。m的值由主函数传入。例如,若m的值为600,则函数的值为3515。 请修改程序中的错误,使它能得到正确结果。 注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include<stdlib.h> #include<stdio.h> #include<conio.h> int proc(int k) int m=0, mc=0; //************found************* while(k>=2) me++; k--; return m; void main() system("CLS"); printf("%d/n", proc(600));
