这题要小心了!幸好有测试数据!(用UE或者命令行fc对比一下,^_^)
Accepted | 1099 | C++ | 00:00.00 | 388K |
#include<stdio.h>
#include <string.h>
int main()
{
#ifndef ONLINE_JUDGE
freopen("1099.txt","r" ,stdin);
freopen("ans.txt","w" ,stdout);
#endif
char str[80 ];
int len = 0 ;
while(scanf("%s",&str) != EOF)
{
if(str[0] == '<' && str[1] == 'h' && len != 0 )
{
printf("/n" );
len = 0 ;
}
while(str[0] == '<' && str[1] == 'h' )
{
if(scanf("%s",&str) == EOF) return 0 ;
printf("--------------------------------------------------------------------------------/n" );
}
if(str[0] == '<' && str[1] == 'b' )
{
printf("/n" );
len = 0 ;
}
else if(len == 0 )
{
printf("%s" ,str);
len = len + strlen(str);
}
else
{
int temp = strlen(str);
len = len + temp + 1 ;
if(len > 80 )
{
printf("/n%s" ,str);
len = temp;
}
else printf(" %s" ,str);
}
}
printf("/n" );
#ifndef ONLINE_JUDGE
fclose(stdin);
fclose(stdout);
#endif
return 0 ;
}
#include <string.h>
int main()
{
#ifndef ONLINE_JUDGE
freopen("1099.txt","r" ,stdin);
freopen("ans.txt","w" ,stdout);
#endif
char str[80 ];
int len = 0 ;
while(scanf("%s",&str) != EOF)
{
if(str[0] == '<' && str[1] == 'h' && len != 0 )
{
printf("/n" );
len = 0 ;
}
while(str[0] == '<' && str[1] == 'h' )
{
if(scanf("%s",&str) == EOF) return 0 ;
printf("--------------------------------------------------------------------------------/n" );
}
if(str[0] == '<' && str[1] == 'b' )
{
printf("/n" );
len = 0 ;
}
else if(len == 0 )
{
printf("%s" ,str);
len = len + strlen(str);
}
else
{
int temp = strlen(str);
len = len + temp + 1 ;
if(len > 80 )
{
printf("/n%s" ,str);
len = temp;
}
else printf(" %s" ,str);
}
}
printf("/n" );
#ifndef ONLINE_JUDGE
fclose(stdin);
fclose(stdout);
#endif
return 0 ;
}