填空题
下列给定的程序中,函数proc()的功能是:判断字符ch是否与str所指字符串中的某个字符相同,若相同,则什么也不做,若不同,则将其插在串的最后。
请修改程序中的错误,使它能得出正确的结果。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
//************found*************
void proc(char str, char eh)
while(*str&&*str! =ch)str++;
//************found*************
if(*str==ch)
str[0]=ch;
//************found***********
str[1]=’0’;
void main()
char str[81], ch;
system("CLS");
printf("\nPlease enter a string: ");
gets(str);
printf("\n Please enter the character to search:");
ch=getchar();
proc(str, oh);
printf("\nThe result is%s\n", str);
【参考答案】
(A)错误:void proc(char str, char ch)
正确:void proc(char*st......
(↓↓↓ 点击下方‘点击查看答案’看完整答案、解析 ↓↓↓)
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
问答题
下列程序定义了M×M的二维数组,并在主函数中赋值。请编写函数proc(),函数的功能是:求出数组周边元素的平均值并作为函数值返回给主函数中的s。例如,若a数组中的值为: a=0 1 2 3 4 5 9 7 4 5 4 3 8 3 6 3 5 6 8 7 2 1 0 9 8 则返回主程序后,S的值为3.750000。 注意:部分源程序已给出。 请勿改动主函数main和其他函数中的任何内容。 试题程序: #include<stdio.h> #include<conio.h> #include<stdlib.h> #define M 5 double proc(int w[][M]) void main() int a[M][M]=0, 1, 2, 3, 4, 5, 9, 7, 4, 5, 4, 3, 8, 3, 6, 3, 5, 6, 8, 7, 2, 1, 0, 9, 8; int i, j; double s; system( CLS ); printf( *****The array***** n ); for(i=0; i<M; i++) for(j=0; j<M; j++) printf( %4d , a[i][j]); printf( n ); s=proc(a); printf( *****THE RESULT***** n ); printf( The sum is: %lf n , s);
点击查看答案&解析
填空题
*str1++! =*str2--
点击查看答案
相关试题
t==0
*str1++! =*str2--
i<=strlen(str) 2
下列程序定义了M×M的二维数组,并在主函数...