题意
略。你能看到我写的题意就是一定知道题到底是个啥玩意。
讲解
你说让我怎样做,我就要去那样做的题目。难度不是太大。 细节处需要注意。
代码
#include <bits/stdc++.h>
using namespace std
;
int main(void)
{
string s
;
int n
;
vector
<char> Y
;
vector
<char> N
;
map
<char, string
> O
;
cin
>> s
;
cin
>> n
;
getchar();
for (string
::size_type i
= 0; i
< s
.length(); i
++)
{
if (s
[i
+1] == ':')
{
Y
.push_back(s
[i
]);
i
++;
continue;
}
N
.push_back(s
[i
]);
}
for (int i
= 0; i
< n
; i
++)
{
string t
;
getline(cin
, s
);
stringstream
ss(s
);
ss
>> t
;
while (ss
>> t
)
{
string tt
;
if (t
.length() == 2)
{
if (t
[0] == '-')
{
if (find(Y
.begin(), Y
.end(), t
[1]) != Y
.end())
{
if (ss
.eof())
break;
ss
>> tt
;
O
[t
[1]] = tt
;
}
else if (find(N
.begin(), N
.end(), t
[1]) != N
.end())
{
O
[t
[1]] = "";
}
else
break;
}
else
{
break;
}
}
else
break;
}
cout
<< "Case " << i
+1 << ": ";
for (map
<char, string
>::iterator it
= O
.begin(); it
!= O
.end(); it
++)
{
if ((*it
).second
== "")
cout
<< "-" << (*it
).first
<< " ";
else
cout
<< "-" <<(*it
).first
<< " " << (*it
).second
<< " ";
}
cout
<< endl
;
O
.clear();
}
return 0;
}
欢迎各位大神交流指导:联系QQ:1364388975
转载请注明原文地址: https://lol.8miu.com/read-24928.html