-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathZOJ1099(AC).cpp
56 lines (52 loc) · 1.03 KB
/
ZOJ1099(AC).cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
int main()
{
char s[2000];
int pos, len;
int type;
//freopen("C:/Users/hp/Documents/Visual Studio 2010/Projects/ZOJ/Debug/in.txt", "r", stdin);
//freopen("C:/Users/hp/Documents/Visual Studio 2010/Projects/ZOJ/Debug/out.txt", "w", stdout);
pos = 0;
type = 1;
while(scanf("%s", s) == 1){
len = strlen(s);
if(strcmp(s, "<br>") == 0){
printf("\n");
pos = 0;
type = 1;
}else if(strcmp(s, "<hr>") == 0){
if(pos > 0){
printf("\n");
pos = 0;
}
printf("--------------------------------------------------------------------------------\n");
pos = 0;
type = 2;
}else{
if(type == 3){
if(pos + len + 1 <= 80){
printf(" %s", s);
pos += len + 1;
}else{
printf("\n%s", s);
pos = len;
}
}else{
if(pos + len <= 80){
printf("%s", s);
pos += len;
}else{
printf("\n%s", s);
pos = len;
}
}
type = 3;
}
}
printf("\n");
return 0;
}