C编程:输入一个正整数repeat (0<repeat<10),做repeat次下列运算: 输入一行字符,分别统计出其中 5
编程:输入一个正整数repeat(0<repeat<10),做repeat次下列运算:输入一行字符,分别统计出其中的英文字母、空格、数字和其他字符的个数。示例:括号内是说...
编程:输入一个正整数repeat (0<repeat<10),做repeat次下列运算: 输入一行字符,分别统计出其中的英文字母、空格、数字和其他字符的个数。
示例:括号内是说明
输入
1 (repeat=1)
Reold building room 123.
输出
letter=17, blank=3, digit=3, other=1
程序:
#include <stdio.h>
void main()
{ int ri, repeat;
int blank, digit, letter, other;
char c;
scanf("%d", &repeat);
getchar();
for(ri=1; ri<=repeat; ri++)
{
c = getchar();
/*--请在此处补全正确的代码--*/
printf("letter=%d, blank=%d, digit=%d, other=%d\n", letter, blank, digit, other);
}
} 展开
示例:括号内是说明
输入
1 (repeat=1)
Reold building room 123.
输出
letter=17, blank=3, digit=3, other=1
程序:
#include <stdio.h>
void main()
{ int ri, repeat;
int blank, digit, letter, other;
char c;
scanf("%d", &repeat);
getchar();
for(ri=1; ri<=repeat; ri++)
{
c = getchar();
/*--请在此处补全正确的代码--*/
printf("letter=%d, blank=%d, digit=%d, other=%d\n", letter, blank, digit, other);
}
} 展开
2个回答
展开全部
#include <stdio.h>
int main( )
{
int ri, repeat;
int blank, digit, letter, other;
char c;
printf("Enter repeated times and the corresponding characters:");
scanf("%d", &repeat);
getchar();
for(ri=1; ri<=repeat; ri++)
{
letter=digit=blank=other=0;
while((c=getchar())!='\n')
{
if((c>='a'&&c<='z')||(c>='A'&&c<='Z'))
letter++;
else if(c>='0'&&c<='9')
digit++;
else if(c==' ')
blank++;
else
other++;
}
printf("letter=%d, blank=%d, digit=%d, other=%d\n", letter, blank, digit, other);
}
return 0;
}
int main( )
{
int ri, repeat;
int blank, digit, letter, other;
char c;
printf("Enter repeated times and the corresponding characters:");
scanf("%d", &repeat);
getchar();
for(ri=1; ri<=repeat; ri++)
{
letter=digit=blank=other=0;
while((c=getchar())!='\n')
{
if((c>='a'&&c<='z')||(c>='A'&&c<='Z'))
letter++;
else if(c>='0'&&c<='9')
digit++;
else if(c==' ')
blank++;
else
other++;
}
printf("letter=%d, blank=%d, digit=%d, other=%d\n", letter, blank, digit, other);
}
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include<stdio.h>
void main()
{
int ri,repeat;
int blank,digit,letter,other;
char c;
scanf("%d",&repeat);
getchar();
for(ri=1;ri<=repeat;ri++)
{
c=getchar();
blank=digit=letter=other=0;
while(c!='\n')
{
if(c>='a'&&c<='z'||c>='A'&&c<='Z')
letter++;
else
if(c>='0'&&c<='9')
digit++;
else
if(c==' ')
blank++;
else
other++;
c=getchar();
}
printf("letter=%d,blank=%d,digit=%d,other=%d\n",letter,blank,digit,other);
}
}
void main()
{
int ri,repeat;
int blank,digit,letter,other;
char c;
scanf("%d",&repeat);
getchar();
for(ri=1;ri<=repeat;ri++)
{
c=getchar();
blank=digit=letter=other=0;
while(c!='\n')
{
if(c>='a'&&c<='z'||c>='A'&&c<='Z')
letter++;
else
if(c>='0'&&c<='9')
digit++;
else
if(c==' ')
blank++;
else
other++;
c=getchar();
}
printf("letter=%d,blank=%d,digit=%d,other=%d\n",letter,blank,digit,other);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询