第4题
第5题
如字符串"Hello World"中,大写字母的个数为2个。
注意:部分源程序已存在文件PROC5.CPP中。
请勿修改主函数和其他函数中的任何内容,仅在函数fun()的花括号中填写若干语句。
文件PROC5.cpp的内容如下:
//PROC5.cpp
include<iostream>
include<string>
using namespace std;
int fun(char *str);
int main()
{
char str[ ]="Chinese Computer World";
cout<<fun(str)<<end;
return 0;
}
int fun(char *str)
{
//**********
}
第6题
例如,输入aeiouAOUpqn,结果为A∶2 E∶1 1∶1 O∶2 U∶2 Other∶4。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
include<stdiO.h>
include<conio.h>
define N 100
void fun(char *str,int bb[ ])
{
char *p=str;
int i=0;
for(i=0;i<6;i++)
【 】;
while(*p)
{
switch(*p)
{
case 'A':
case 'a':bb[0]++;break;
case 'E':
case 'e':bb[1]++;break;
case 'I':
case 'i':bb[2]++;break;
case 'O':
case 'o':bb[3]++;break;
case 'U':
case 'u':bb[4]++;break;
default:【 】;
}
【 】
}
}
main()
{
char str[N),ss[6]="AEIOU";
int i;
int bb[6];
clrscr();
printf("Input a string:\n");
gets(str);
printf("the string is:\n");
puts(str);
fun(str,bb);
for(i=0;i<5;i++)
printf("\n%c:%d",ss[i],bb[i]);
printf("\nother:%d",bb[i]);
}
第7题
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include<string. h>
include<stdio, h>
define N 80
int fun (char *s)
{
}
main ( )
{
char line [N];
int num=0;
printf ("Enter a string: \n ");
gets (line);
num=fun (line);
printf ("The number of word is: %d\n\n ",
num);
}
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!