HDU 1088
来源:互联网 发布:qq内部人员软件 编辑:程序博客网 时间:2024/05/17 01:58
//这里主要是用n来标记看是否是在一行的开头!当n=0时,就在开头,否则就不在!//还有就是不要用scanf来输入字符串,这样会超时,这题就用scanf超时了,用cin就//AC了,奇葩啊!一般cin的时间会比scanf多啊!#include <iostream>#include <cstring>#include <cstdio>using namespace std;char s[81];int n;int main(){ while((cin>>s)!=NULL) { int i,len; if(strcmp(s,"<br>")==0) { n=0; printf("\n"); } else if(strcmp(s,"<hr>")==0) { if(n!=0) { printf("\n"); } for(i=0; i<80; i++) { printf("-"); } printf("\n"); n=0; } else { if(n==0) { n+=strlen(s); printf("%s",s); } else { n+=strlen(s)+1; if(n<=80) { printf(" %s",s); } else { printf("\n"); printf("%s",s); n=strlen(s); } } } } if(n!=0) printf("\n"); return 0;}