

C++语言:
Codee#28130
01
#include
02
#include
03
04
using
namespace
std;
05
06
int
judge(string
ball){
07
int
s_length=ball.length();
08
if
(s_length<9){
09
return
1;
10
}
11
// char* temp = new char(s_length+1); 这样做好像会造成内存分配问题,暂时找不到解决办法
12
char
temp[
100];
//所以改为了这样,直接静态分配了,之前也是死脑筋了,想要用length
13
sprintf(temp
,
"%s"
,
ball.c_str());
14
if(temp[s_length-
8]==
' '&&temp[s_length-
7]==
'n'&&temp[s_length-
6]==
'o'&&temp[s_length-
5]==
' '){
15
return
0;
16
}
17
else
{
18
return
1;
19
}
20 }
21
22
int
jfp(
int
N,string
s[],
int
n){
23
int
goal[
18]={
0};
24
int
i=
0;
25
int
jfq_up=
0;
26
int
jfq_down=
0;
27
for
(i=
0;i
28
goal[i]=judge(s[i+(
18*n)]);
29
}
30
for
(i=
0;i2){
31
if
(goal[i]==
1){
32
cout<<
"O"<<
" ";
33
jfq_up++;
34
}
35
else
cout<<
"X"<<
" ";
36
}
37
cout<<jfq_up<<endl;
38
for
(i=
1;i2){
39
if
(goal[i]==
1){
40
cout<<
"O"<<
" ";
41
jfq_down++;
42
}
43
else
cout<<
"X"<<
" ";
44
}
45
if
(N%
2==
1)
cout<<
"-"<<
" ";
46
cout<<jfq_down<<endl;
47
return
0;
48 }
49
50
int
main(){
51
int
N[
100];
52
string
s[
1800];
53
string
l;
54
int
i=
0;
55
int
j=
0;
56
int
temp=
0;
57
int
jfq=
0;
58
while(
1){
59
cin>>N[j];
60
if(N[j]==
0)
break;
61
getline(cin,l);
62
for(i=temp;i<(temp+N[j]);i++){
63
getline(cin,s[i]);
64
}
65
j++;
66
temp=temp+
18;
67
};
68
int
N_nub=j;
69
for
(i=
0;i
70
for
(j=
0;j<(N[i]+
1)/
2;j++){
71
cout<<j+
1<<
" ";
72
}
73
cout<<
"Score"<<endl;
74
jfp(N[i],s,i);
75
}
76
system(
"pause");
77
return
0;
78 }
02
03
04
05
06
07
08
09
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
题不算难,关键是一直想要动态分配(也是强迫症发作),结果又解决不了内存泄露(?)的问题。
算是又复习了一下动态数组的定义,学到了两个新函数cin.get() 和getlint()。