填空题请补充main函数,该函数的功能是:从字符串str中取出所有数字字符,并分别计数,然后把结果保存在数组b中并输出,把其他字符保存在N[10]中。 例如:当str1=“ab123456789cde090”时,结果为: 0: 2 1: 1 2: 1 3: 1 4: 1 5: 1 6: 1 7: 1 8: 1 9:2 other charactor:5 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。 试题程序: #include <stdio.h> #include <conio.h> main() int i,b[11]; char *str="abl23456789cde090"; char *p=str; clrscr(); printf("***the origial data ***/n"); puts(str); for(i=0;i<11;i++) b[i]=0; while(*p) switch( 【1】 ) case '0':b[0]++;break; case '1':b[1]++;break; case '2':b[2]++;break; case '3':b[3]++;break; case '4':b[4]++;break; case '5':b[5]++;break; case '6':b[6]++;break; case '7':b[7]++;break; case '8':b[8]++;break; case '9':b[9]++;break; 【2】 【3】 printf("****** the result ********/n"); for(i=0;i<10;i++) printf("/n%d:%d",i,b[i]); printf("/nother charactor:%d",b[i]);
填空题以下函数的功能是计算s=1+1/21+1/3!+…+1/n!,请填空。
double fun(int n)
{ double s=0.0,fac=1.0;
int i,k=1;
for(i=1;i<=n;i++)
{ {{U}} 【14】 {{/U}};
fac=fac/k;
s=s+fac;
}
}
填空题有序线性表进行二分查找的前提是该线性表必须是 [1] 存储的。
填空题str是一个由数字和字母字符组成的字符串,由变量num传入字符串长度。请补充函数fun(),该函数的功能是:把字符串str中的数字字符转换成数字并存放到整型数组bb中,函数返回数组bb的长度。
例如:str=“Bcdl23e456hui890”,结果为:123456890。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#define N 80
int bb[N];
int fun(char s[ ],int bb[ ],int num)
{
int i,n=0;
for(i=0;i<num;i++)
{
if({{U}} 【1】 {{/U}})
{
bb[n]={{U}} 【2】 {{/U}};
n++;
}
}
return{{U}} 【3】 {{/U}};
}
main()
{
char str[N];
int num=0,n,i;
printf("Enter a string:/n");
gets(str);
while(str[num])
num++;
n=fun(str,bb,num);
printf("/nbb=");
for(i=0;i<n;i++)
printf("%d",bb[i]);
}
填空题若x为血类型,请写出与!x等价的C语言表达式______。
填空题下面程序的功能是:将一个5行5列矩阵(用二维数组表示)主次两条对角线上的元素依次赋值为1,2,3,4,5和5,4,3,2,1。空白处应填的是______。
main()
{int (a[5][5],i;
for(i=0;i<=4;i++)
{______;
______; }
}
填空题给定程序中,函数fun()的功能是:把形参s所指字符串中下标为奇数的字符右移到下一个奇数位置,最右边被移出字符串的字符绕回放到第一个奇数位置,下标为偶数的字符不动(注:字符串的长度大于等于2)。
例如,形参s所指的字符串为:abcdefgh,执行结果为:ahcbedgf。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在fun()函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
void fun(char*s)
{
int i,n,k;
char c;
n=0;
for(i=0;s[i]!="/0";i++)
n++;
if(n%2==0)
k=n-______;
else
k=n-______;
c=s[k];
for(i=k-2;i>=1;i=i-2)
s[i+2]=s[i];
s[1]=______;
}
void main()
{
char s[80]="abcdefgh";
printf("/nThe original string is:%s/n",s);
fun (s);
printf("/nThe result is:%s/n",s);
}
填空题请补充函数fun(),该函数的功能是按条件删除一个字符串指定字符一半的数目,具体要求如下:如果该字符串所包含的指定字符的个数是奇数,则不予删除,如果其数目是偶数,则删除原串后半部分的指定字符。其中,a指向原字符串,删除后的字符串存放在b所指的数组中,c中存放指定的字符。
例如:当a输入“abababa”,c=‘a’时,b的输出为“ababb”;
如果a的输入为“ababa”,则b的输出为“ababa”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#define LEN 80
void fun(char a[],char b[],char C)
{
int i=0,j=0;
int n=0;
int m=0;
while(a[i]!=‘/0’)
{
if(a[i]==c)
n++;
i++;
}
{{U}} {{U}} {{/U}} {{/U}};
if(n%2)
{
while(a[j]!='/0')
{
b[j]=a[j];
j++;
}
b[j]='/0';
}
else
{
while(a[i]!='/0')
{
b[j++]=a[i];
if(a[i]==c)
m++;
if((m>n/2)&&(a[i]==c))
{{U}} {{U}} {{/U}} {{/U}};
i++;
}
{{U}} {{U}} {{/U}} {{/U}};
}
}
main()
{
char a[LEN],b[LEN];
char c;
clrscr();
printf("Enter the string:/n");
gets(a);
printf("Enter the character of the string deleted:");
scanf("%c",&c);
fun(a,b,c);
printf("The new string is:%s/n",b);
}
填空题以下程序运行后的输出结果是______。 main() int a=3,b=4,c=5,t=79; if(b<a&&a<c)t=a;a=c;c=t; if(a<c&&b<c)t=b;b=a;a=t; printf("%d%d%d/n",a,b,c);
填空题有以下程序段,且变量已正确定义和赋值 for(s=1.0,k=1;k<=n;k++)s=s+1.0/(k*(k+1)); printf("s=%f/n/n",s); 请填空,使下面程序段的功能与之完全相同 s=1.0;k=1; while( 【8】 )s=s+1.0/(k*(k+1)); 【9】 ; printf("s=%f/n/n",s);
填空题下面程序的运行结果是 【13】 。 #include<stdio.h> #define SIZE 12 main() char s[SIZE];int i;for(i=0;i<SIZE;i++) s[i]='A'+i+321; sub(s,7,SIZE-1); for(i=0;i<SIZE;i++) printf("%c",s[i]); printf("/n"); sub(char *a,int t1,int t2) char ch; while(t1<t1) ch=*(a+t1); *(a+t1)=*(a+t2); *(a+t2)=ch; t1++;t2--;
填空题从键盘:输入一组无符号整数并保存在数组xx[N]中,以整数0结束输入,要求这些数的最大位数不超过4位,其元素的个数通过变量num传入函数fun()。请补充函数fun(),该函数的功能是:从数组xx中找出个位和十位的数字之和大于5的所有无符号整数,结果保存在数组yy中,其个数由函数fun()返回。
例如:当xx[8]=<123,11,25,222,42,333,14,5451}时,
bb[4]={25,42,333,5451}。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio.h>
#define N 1000
int fun(int xx[ ],int bb[ ],int num)
{
int i,n=0;
int g,s;
for(i=0;i<num;i++)
{
g={{U}} 【1】 {{/U}};
s=xx[i]/10%10;
if((g+s)>5)
{{U}}【2】 {{/U}};
}
return{{U}} 【3】 {{/U}};
}
main()
{
int xx[N];
int yy[N];
int num=0,n=0,i=0;
printf("Input number:/n");
do
{
scanf("%u",&xx[num]);
}
while(xx[num++]!=0);
n=fun(xx,yy,num);
printf("/nyy=");
for(i=0;i<n;i++)
printf("%u",yy[i]);
}
填空题下列程序的运行结果是______。
main()
{ int a=1,b=10;
do
{ b-=a;a++;}while(b--<0) ;
printf("%d,%d/n",a,B) ;
}
填空题以下程序运行后的输出结果是______。 main() int a=3,b=2,c=1; if(c=a) printf("%d/n",c); else printf("%d/n",b);
填空题以下fun函数的功能是:累加数组元素中的值,n为数组中元素的个数,累加的和值放入x所指的存储单元中。请填空。
fun(int b[ ],int n,int * x)
{ int k,r=0;
for(k=0,k<n;k + +)r={{U}} 【7】 {{/U}};
{{U}} 【8】 {{/U}}=r;
}
填空题当调用函数时,实参是一个数组名,则向函数传递的是______。
填空题以下程序的功能是:借助指针变量找出数组元素中的最大值及其元素的下标值。请填空。
#include
main()
{ int a[10],*p,*s;
for(p=a;p-a*s) s= 【 】 ;
printf(“index=%d/n”,s-a);
}
填空题以下程序的输出结果是 【17】 。 int fun(int *x,int n) if(n==0) return x[0]; else return x[0]+fun(x+1,n-1); main() int a[]=1,2,3,4,5,6,7; printf("%d/n",fun(a,3));
填空题有以下程序段,且变量已正确定义和赋值。 for(s=1.0, k=1; k<=n;k++) s=s+1.0/(k*(k/1)); printf("s=%f/n/",s); 请填空,使下面程序段的功能与之完全相同。 s=1.0; k=1; while( 【10】 ) s=s+1.0/(k*(k+1)); 【11】 ; printf("s-=%f/n/n",s);
填空题以下程序运行后的输出结果是______。 #include <strlng.h> main() char ch[]="abc",x[3][4]; int i; for(i=0;i<3;i++) strcpy(x[i],ch); for(i=0;i<3;i++) printf("%s",&x[i][i]); printf("/n");