C语言一个题目错误Input:今有若干篇小说,每篇小说以#为结束(文中不会出现#).Output:输出每篇小说的主角名字,每个名字占一行.Sample Input:Several pages before the novel actually ends,@Thackeraywrites a fake e

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/08 18:06:08

C语言一个题目错误Input:今有若干篇小说,每篇小说以#为结束(文中不会出现#).Output:输出每篇小说的主角名字,每个名字占一行.Sample Input:Several pages before the novel actually ends,@Thackeraywrites a fake e
C语言一个题目错误
Input:
今有若干篇小说,每篇小说以#为结束(文中不会出现#).
Output:
输出每篇小说的主角名字,每个名字占一行.
Sample Input:
Several pages before the novel actually ends,@Thackeray
writes a fake ending,to satirize conventional happy endings.
He deliberately throws in a repetitious series of cliches
often used for endings–the vessel is in port,the hero gets
what he yearned for all his life,and the bird comes home and
sits on his shoulder billing and cooing.Then @Thackeray has
prose swells into a crescendo of sentimentality and more
repetition:"This is what he has asked for every day and hour
for eighteen years.This is what he pined after.Here it is–the
summit,the end–the last page of the third volume".Then he
bids goodbye to @Dobbin and @Amelia ,and of course slips in
the reference to her as a parasite.The repetition points up
the lack of real meaning and the indulgence of emotion for
its own sake.Unwary readers,in his day and ours,accept his
statement and emotion at face value,ignore the parasite
reference,and so miss the satire.Not even the fact that the
novel was published in two volumes,not three,alerted some
of his contemporaries.The style and sentimentality of
@Thackeray false ending are similar to passages that @Dickens
wrote.
#
Sample Output:
Thackeray
#include
#include
struct data
{
char name[1000];
int x;
}a[1000];
main()
{
char c;
int i,j,k=0,l=0,m=0,max;
while(1)
{
while((c=getchar())!='#')
{
if(c=='@')
k++;
else if(k>0)
{
if(c!=' '&&c!='@')
{a[l].name[m]=c;
m++;}
else if(c==' ')
{k=0;l++;m=0;}
}
}
for(i=0;i

C语言一个题目错误Input:今有若干篇小说,每篇小说以#为结束(文中不会出现#).Output:输出每篇小说的主角名字,每个名字占一行.Sample Input:Several pages before the novel actually ends,@Thackeraywrites a fake e
你的程序写的实在太复杂了.我给你写了一个简单的程序.
#include
#include
int main(void)
{
char c;
while(1)
{
c = getchar();
if (c =='#')
return 0;
else if (c == '@'){
c = getchar();
while (c != ' ')
{
if (c != '\n')
putchar(c);
c = getchar();
}
putchar('\n');
}
}
}
中间加了这一行语句
if (c != '\n')
是由于
Several pages before the novel actually ends, @Thackeray
writes a fake ending, to satirize conventional happy endings.
的换行符在空格之前的原因.
我用的是linux的操作系统,换行为\n,