#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <map>
using namespace std;
int main()
{
freopen("DATA3.txt","r",stdin);
freopen("DATA33.txt","w",stdout);
int k;
string name,costume;
for(int z = 0; z < 5;z++)
{
cin >> k;
vector<string> friends;
vector<string> costumes;
for (int i = 0 ; i < k; i++)
{
cin >> name >> costume;
bool found = false;
for (int j = 0; j < costumes.size();j++)
{
if (costumes[i] == costume) found = true;
}
if (found)
friends.push_back(name);
else
costumes.push_back(costume);
}
if (!costumes.size()) cout << "SPOOKY\n";
else
{
for (int i = 0; i < costumes.size();i++)
{
if ( i == costumes.size())
cout << costumes[i];
else
cout << costumes[i] << " ";
}
}
cout << endl;
}
}
每当我尝试运行此代码时,它都会说 3.exe 已停止工作。为什么是这样?我检查了文本文件,一切都很好。任何对问题的实际上下文感兴趣的人http://www.dwite.ca/questions/costume_party.html