C++ code crashes when ran -
#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; (int = 0 ; < k; i++) { cin >> name >> costume; bool found = false; (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 { (int = 0; < costumes.size();i++) { if ( == costumes.size()) cout << costumes[i]; else cout << costumes[i] << " "; } } cout << endl; } }
whenever try run code says 3.exe has stopped working. why this? i've checked text files , everythings fine. anynoe interested in actual context of problem http://www.dwite.ca/questions/costume_party.html
if (costumes[i] == costume) // iterating through j=0 costumes.size(), change if (costumes[j] == costume).
Comments
Post a Comment