填空题
下列给定程序中,函数proc()的功能是:依次取出字符串中所有的字母字符,形成新的字符串,并取代原字符串。
例如,若输入的字符串是:ab232bd34bkw,则输出结果是:abbdbkw。
请修改程序中的错误,使它能得到正确结果。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
void proc(char * str)
int i, j;
for(i=0, j=0; str[i]!=’\0’; i++)
//************found*************
if((str[i]>=’A’ &&str[i]<=’z’)&&(str[i]>=’a’&&str[i]<=’z’))
str[j++]=str[i];
//************found*************
str[j]="\0";
void main()
char item[80];
system("CLS");
printf("\nEnter a string: ");
gets(item);
printf("\n\nThe string is:%s\n", item);
proc(item);
printf("\n\nThe string of changing is: %sin", item);
【参考答案】
此题暂无答案,小编努力补充中……
热门
试题
问答题
学生的记录由学号和成绩组成,M名学生的数据已在主函数中放入结构体数组S中,请编写函数proc(),它的功能是:把分数最高的学生数据放在h所指的数组中。注意:分数高的学生可能不只一个,函数返回分数最高学生的人数。 注意:部分源程序已给出。 请勿改动主函数main和其他函数中的任何内容。 试题程序: #include<stdio.h> #define M 16 typedef struct char num[10]; int s; STREC; int proc(STREC * a, STREC*b) void main() STREC stu[M]= GA005 , 85, GA003 , 76, GA002 , 69, GA004 , 85, GA001 , 91, GA007 , 72, GA008 , 64, GA006 , 87, GA015 , 85, GA013 , 91, GA012 , 64, GA014 , 91, GA011 , 66, GA017 , 64, GA018 , 64, GA016 , 72; STREC h[M]; int i, n; n=proc(stu, h); printf( The %d highest score: n , n); for(i=0; i<n; i++) printf( % S%4d n , h[i]. num, h[i].s); 输出最高分学生的学号和成绩 printf( n );