填空题 C语言
题号 #2257387

请补充函数proc(),该函数的功能是:分类统计一个字符串中元音字母和其他字符的个数(不区分大小写)。
例如,输入imnlaeouOWC,结果为:A:1 E:1 1:2 0:2 U:1 other:4。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#define M 100
void proc(char*str,int bb[])
{
char*p=str;
int i=0:
for(i=0;i<6;i++)
【1】 ;
while(*p)
{
switch(*p)
{
case'A ':
case'a':bb[0]++;break;
case 'E':
case'e ':bb[1]++;break;
case '1':
case'i':bb[2]++;break;
case'0':
case'o':bb[a]++;break;
case 'U':
case'u':bb[4]++;break;
default:【2】;
}
【3】
}
}
void main()
{
char str[M],ss[6]="AEIOU";
int i;
int bb[6];
system("CLS");
printf("Input a string:\n");
gets(str);
printf("the string is:\n");
puts(str);
proc(str,bb);
for(i=0;i<5;i十+)
printf("\n%c:%d",ss[i],bb[i]);
printf("\nother:%d",bb[i]);
}

进入在线模考

参考答案

暂无

答案解析

【1】bb[i]=0【2】bb[5]++【3】p++;
【解析】由函数proc()可知,数组b中存放的是各个元音字母和其他字符的个数,其初始化为0,因此,【1】处填“})}) [i]=0”;由switch语句可知,h[5]中存放的是其他字符的个数,每检查到一个元音以外的其他字符,b[5]加1,因此.【2】处填“bb[5]++”;指针变量p指向字符串中的字符,每检查完一个字符,指针p要向后移动一个位置.因此’【3】处填“p++”。

你可能感兴趣的试题

2

学生的记录由学号和成绩组成,M名学生的数据已在主函数中放人结构体数组stu中,请编写函数proc(),它的功能是:把指定分数范围之外的学生数据放在b所指的数组中,分数范围之外的学生人数由函数值返回。
例如,输入的分数是70和79,则应当把分数低于70和高于79的学生数据输出,不包含70分和79分的学生数据。主函数中把70放在low中,把79放在heigh中。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的花括号中填人所编写的若干语句。
试题程序:
#include<stdio.h>
#define M 16
typedef struct
{
char num[10];
int s:
}
STREC;
int proc(STREC*a,STREC*b,int 1,int h)
{

}
void main()
{
STREC stu[M]={{"GA005",55),{"GA003",96},
{"GA002",80),{"GA004",68),
{"GA001",88},{"GA007",74},
{"GA008",85),{"GA006",89},
{"GA015",90),{"GA013”,53),
{"GA012",66},{"GA014”,82),
{"GA011",73},{"GA017",69),
{"GA018",64),{"GA016",86}};
STREC h[M];
int i,n,low,heigh,t;
printf("Enter 2 integer number low&
heigh:");
scanf("%d%d",&low,&heigh);
if(heigh<low) ’
{
t=heigh:
heigh=low;
low=t;
}
n=proc(stu,h,low,heigh);
printf("The student’S data out
%d--%d:\n",low,heigh);
for(i=0;i<n;i++)
printf("%S%4d\n",h[i].num,h[i].s);
//输出指定分数范围内的学生记录
printf("\n");
}

找试题 · 找答案 · 找资料 在线模考