ZOJ1099字符串水题

来源:互联网 发布:手机蓝牙软件下载 编辑:程序博客网 时间:2024/05/19 12:29
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
int count=0;
char word[81];
while(scanf("%s",word)!=EOF)
{
if(strcmp(word,"<hr>")==0)
{
if(count!=0)
printf("\n");
int i;
for(i=0;i<80;i++)
printf("-");
printf("\n");
count=0;
}
else if(strcmp(word,"<br>")==0)
{
printf("\n");
count=0;
}
else
{
if(count+strlen(word)+(count==0?0:1)>80)
{
printf("\n%s",word);
count=strlen(word);
}
else
{
if(count!=0) printf(" ");
printf("%s",word);
count+=strlen(word)+1;
}
}
}
printf("\n");
return 0;
}
0 0
原创粉丝点击