水题求c++的程序解答

[复制链接]
查看11 | 回复1 | 2021-1-27 07:14:08 | 显示全部楼层 |阅读模式
Description
编写一个程序,要求统计输入文本的行数。
Input
每行输入任意长度的字符串(每一行的字符串的长度小于等于1000),以输入仅由符号@构成的行作为结束,@所在的行不计入行数。
Output
输出文本的行数。
SampleInput
Helloworld!
IcomefromChina!
I’maboy!
@
SampleOutput
3

分 -->
回复

使用道具 举报

千问 | 2021-1-27 07:14:08 | 显示全部楼层
#include
intmain(void)
{
charstr[100][1000];
inti=1,j=1;
printf("Pleaseinput:\n");
for(i=0;;i++)
{
for(j=0;;j++)
{
scanf("%c",&str[j]);
if(str[j]=='\n')
break;
elseif(str[j]=='@')
gotoloop;
}
}
loop:
printf("Thetotalhadentered%drows\n",i);
return0;
}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行