填空题请补充main函数,该函数的功能是:从键盘输入一个字符串并保存在字符str1中,把字符串str1中下标为偶数的字符保存在字符串str2中并输出。例如,当str1=“cdefghij”,则 str2=“cegi”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#define LEN 80
main()
{
char str1[LEN],str2 [LEN];
char *p1=str1,*p2=str2;
int i=0,j=0;
clrscr();
printf("Enter the string:/n");
scanf({{U}} {{U}} {{/U}} {{/U}});
printf("***the origial string***/n");
while(*(p1+j))
{
printf("{{U}} {{U}} {{/U}} {{/U}}",*(p1+j));
j++;
}
for(i=0;i<j;i+=2)
*p2++=*(str1+i);
*p2='/0';
printf("/nThe new string is:%s/n",{{U}} {{U}} {{/U}} {{/U}});
}
填空题为了建立如图所示的存储结构(即每个结点含两个域,data是数据域,next是指向结点的指针域)。请填空。structlinkchardata;【19】;node;
填空题若输入字符串;abcde,则以下while循环体将执行【12】次。while((ch=getchar())=='e')printf("*");
填空题给定程序中,函数fun的功能是求矩阵(二维数组)a[N][N]中每行的最小值,结果存放到数组b中。假如:若则结果应为1,5,9,13,请改正函数fun中指定部位的错误,使它能得出正确的结果。注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。试题程序:#include<stdio.h>#defineN4voidfun(inta[][N],intb[]){inti,j;for(i=0;i<N;i++){/*********found*********/b[i]=a[0][0];/*********found*********/for(j=1;j<N-1;j++)/*********found*********/if(b[i]<a[i][j])b[i]=a[i][j];}}main(){inta[N][N]={{1,4,3,2},{8,6,5,7},{11,10,12,9},{13,16,14,15}},b[N];inti;fun(a,b);for(i=0;i<N;i++)printf("%d,",b[i]);printf("/n");}
填空题以下程序统计从终端输入的字符中大写字母的个数,num[0]中统计字母A的个数,num[1]中统计字母B的个数,其他依此类推。用#号结束输入,请填空。 #include<stdio.h> #include<ctype.h> main() int num[26]=0,i;char c; while((______)!='#') if(isupper(c))num[c-'A']=______; for(i一0;i printf("%c:%d",i+'A',num);
填空题49. 有以下程序; int a=2; int f(int *A) return(*A) ++; main() int s=0; int a=5; s+=f(&A) s+=f(&A) printf("%d//n",s) 执行后的输出结果是{{U}} {{/U}}。
填空题以下程序运行后的输出结果是【6】。
#include
main()
{ int a;
a=(int)((double)(3/2)+0.5+(int)1.99*2);
printf("%d\n",a);
}
填空题请补充main函数,该函数的功能是:输入两个正整数m和n,求这两个数的最大公约和最小公倍数。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。 试题程序: #include <stdio.h> main ( ) int a, b, n, m, t; clrscr (); printf ("/nInput two numbers: /n"); scanf ("%d, %d", if (n<m) a=m; b=n; else a=n; b=m; while( 【1】 ) t= 【2】 a=b; b=t; printf ("greatest con. non divisor: %d/n", a); printf ("least common multiple: %d/n", 【3】 );
填空题以下程序的输出结果是 【12】 。 fun(int x,int y,int z) z=x*x+y*y; main() int a=31 fun(6,3,a) printf("%d",a)
填空题下列给定程序中,函数fun()的功能是:计算S=f(-n)+f(-n+1)+…+f(0)+f(1)+f(2)+…f(n)的值。例如,当n为5时,函数值应为10.407143。f(x)函数定义如下:请改正程序中的错误,使它能得山正确的结果。注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。试题程序:#include<conio.h>#include<stdio.h>#include<math.h>/**************found***************/f(doublex){if(x==0.0||x==2.0)return0.0;elseif(x<0.0)return(x-1)/(x-2);elsereturn(x+1)/(x-2);}doublefun(intn){inti;doubles=0.0,y;for(i=-n;i<=n;i++){y=f(1.0*i);s+=y;}/**************found**************/returns}main(){clrscr();printf("%f/n",fun(5));}
填空题下列程序的运行结果是 【16】 。 main() union EXAMPLE struct int x;int y;in; int a; int b; e: e.a=1;e.b=2; e.in.x=e.a*e.b; e.in.y=e.a+e.b; printf("%d,%d/n",e.in.x,e.in.y);
填空题如下语句printf("%c/n",'B'+40);在执行后的输出结果是 【11】 。
填空题以下程序的输出结果是 【9】 。 main() int a=0; a+=(a=8); printf("%d/n",a);
填空题以下程序的输出结果是______。
main()
{
int arr[]={30,25,20,15,10,5},*p=arr;
p++;
printf("%d/n",*(p+3));
}
填空题为表示关系x>y>z的c语言表达式是______。
填空题下面程序的功能是将字符串a下标值为偶数的元素由小到大排序,其他元素不变,请填空。 #include<stdio.h> main() char a[]="labchmfye",t; int i,j; for(i=0;i<7;i+=2) for(j=i+2;j<9; 【15】 ) if( 【16】 ) t=a[i]; a[i]=a[j]; a[j]=t;j++; puts(a); printf("/n");
填空题表达式10+'a'+1.5-0.5*'B'的结果是 【7】 。
填空题设有定义语句:int a[][3]={{0},{1}{2}};,则数组元素a[1][2]的值是{{U}} 【13】 {{/U}}。
填空题下列程序的功能是:求出ss所指字符串中指定字符的个数,并返回此值。 例如,若输入字符串123412132,输入字符1,则输出3,请填空。 #include<conio.h> #include<stdio.h> #define M 81 int fun(char*ss,char c) int i=0; for(;______;ss++) if(*ss==c)i++; return i; main() char a[M],ch; printf("/nPlease enter a string:");gets(a); printf("/nPlease enter a char:");ch=getchar(); printf("/nThe number of the char is:%d/n",fun(a,ch));
填空题下列程序按下面指定的数据给X数组,并按如下形式输出,请填空。 4 3 7 2 6 9 1 5 8 1 0 #include<stdio.h> main() int x[4][4],n=0,i,j; for(j=0;j<4;j++) for(i=3;i>=j;______)(n++;x[i][j]=______;) for(i=0;i<4;i++) for(j=0;j<=i;j++)printf("%3d",x[i][j]); printf("/n");
