原题:http://acm.hdu.edu.cn/showproblem.php?pid=1088
题意:
1、遇到<br>换行;
2、遇到<hr>输出
“--------------------------------------------------------------------------------”
3、每行长度不得超过80,单词间有空格;
#include<stdio.h>
#include<string.h>
char str[1500];
int lon = 0;
int main()
{
while(scanf("%s", str)!=EOF)
{
if(strcmp(str, "<br>") == 0)
{
lon = 0;
printf("\n");
}
else if(strcmp(str, "<hr>") == 0)
{
if(!lon)
printf("--------------------------------------------------------------------------------\n");
else
printf("\n--------------------------------------------------------------------------------\n");
lon = 0;
}
else
{
int len = strlen(str);
if(!lon)
{
printf("%s", str);
lon = len;
}
else if(lon+len+1>80)
{
printf("\n%s", str);
lon = len;
}
else
{
printf(" %s", str);
lon+=len+1;
}
}
}
printf("\n"); //结束换行
return 0;
}