第1题
连接到t的后面。例如,当s中的字符串为WXYZ时,则t中的字符串应为WXYZWXYZ。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: include<stdlib.h> include<conio.h> include<stdio.h> include<string.h> void proc(char*s,char*t) { int i,s1; s1=strlen(s); for(i=0;i<s1;i++) //****found**** t[i]=s[s1]; for(i=0;i<s1;i++) t[s1+i]一s[i]; t[2*s1]=\O0; } void main { char s[100],t[100]; system("CLS"); print{("\nPlease enter string s:"); scanf("%s",s); proc(s,t); printf("The result is:%s\n",t); }
第2题
所有字符全部删除。结果仍然保存在原串中。 例如,输入“abcdefg”,指定字符为“d”,则输出“abe”。 注意:部分源程序给出如下。 请勿改动main函数和其他函数中的任何内容,仅在main函数的横线上填入所编写的若干表达式或语句。 试题程序: include<stdlib.h> include<stdio.h> define M 80 void main { int i=0; char str[M]; char ch; system("CLS"); printf("\n Input a strin9:\n"); gets(str); printf("\n Input a charator;\n"); scanf("%c",&ch); while(str[i]!=\0) { if(str[i]==ch) 【1】 【2】 ; } str[i]=【3】 ; printf("\n***display string***\n"); puts(str); }
第3题
如,若主函数从键盘给n输入20后,则输出为S= 0.680803。 注意:部分源程序给出如下。 请勿改动main函数和其他函数中的任何内容,仅在函数proc的花括号中填入所编写的若干语句。 试题程序: include t:stdio.h> double proc(int n) { } void main { int n; double slim; printf("\nInput n:"); scanf("%d",&n); sum=proc(n)。 printf("\ns=%f\n",sum); }
第4题
有序。 例如,在数组bb[M]={10 20 30 40 50 60 70 80 85 95} 中插入75,结果为 bb[M]={10 20 30 40 50 60 70 75 80 85 95} 注意:部分源程序给出如下。 请勿改动main函数和其他函数中的任何内容,仅在main函数的横线上填入所编写的若干表达式或语句。 试题程序: include<stdlib.h> include<stdio.h> define M 10 void main { int i,j; int n; int bb[M+1]={10,20,30,40,50,60,70,80,85,95}; system("CLS"); printf("\nlnput n n"); scanf("%d",&n); printf("\nn=%d",n); printf("\n***original list***\n"); for(i=0;i<M;i++) printf("%4d",bb[i]); for(i=0;i<M;i++) { if(n<=bb[i]) { for(j==M;【1】 ;j--) 【2】 ; bb[j]=n; 【3】 ; } } if(i==M) bb[i]=n: printf("\n****new list****\n"); for(i=0;i<M+1;i++) printf("%4d",bb[i]); }
第5题
编写函数fun(),它的功能是;根据以下公式求p的值,结果由函数值带回。m与n为两个正数且要求m>n。
P=m!/n!(m-n)!),例如:m=12,n=8时,运行结果为495.000000。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include <conio.h>
include <stdio.h>
float fun (int m, int n)
{
}
main()
{
clrscr() ;
printf ("p=%f\n", fun (12,8) ) ;
}
第6题
设有如下程序:
main()
{int n1,n2;
scanf("%d",&n2);
while(n2!=0)
{ n1=n2%10;
n2=n2/10;
printf("%d",n1);
}
}
程序运行后,如果从键盘上输入1298,贝愉出结果为【 】。
第7题
以下程序的功能是输出如下形式的方阵:
13 14 15 16
9 10 11 12
5 6 7 8
1 2 3 4
请填空。
main()
{ int i,i,x;
for(j=4; j______; j--)
{ for(i=1; i<4; i++)
{ x=(j-1)*4+______;
printf("%4d",x);
}
printf("\n");
}
第8题
值返回,平均分存放在形参aver所指的存储单元中。例如输入8名学生的成绩:
80.5 60 72 90.5 98 51.5 88 64
则低于平均分的学生人数为4(平均分为75.5625)。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
include <stdio.h>
include <conio.h>
define N 20
int fun(float *s, iht n,float *aver)
{ float ave ,t=0.0;
int count=0,k,i;
for(k=0;k<n;k++)
/*************found**************/
t=s[k];
ave=t/n;
for(i=0;i<n;i++)
if(s[i]<ave) count++;
/*************found**************/
*aver=&ave;
return count;
}
main()
{ float s[30],aver;
int m,i;
clrscr();
printf("\nPlease enter m: "); scanf
("%d",&m);
printf("\nPlease enter %d mark :\n",m);
for(i=0;i printf("\nThe number of students :
%d\n",fun(s,m,&aver));
printf("Ave=%f\n",aver);
}
第9题
串。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
include<stdio.h>
include<conio.h>
void fun(char *s)
{
int i=0;
char *p=s;
while(【 】)
{
if (*p>='a'&&*p<='z')
{
s[i]=*p;
【 】;
}
p++;
}
s[i]=【 】;
}
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);
}
第10题
数;并把该整数中各位上最大的数字值作为函数值返回。例如,若输入无符号整数30800,则数字值为零的个数为3,各位上数字值最大的是8。
请改正函数fun中指定部位的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!