fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <iterator>
  4. using namespace std;
  5.  
  6. int main() {
  7. string forname, surname, role, strF = "Tina", strS = "Weymouth";
  8. int bandnum;
  9. vector<string> band;
  10.  
  11. while (cin >> forname >> surname >> bandnum)
  12. {
  13. band.clear(); //Clean up the vector so it'll only store the current artist's bands
  14. for (int i = 0; i < bandnum; i++)
  15. {
  16. string tmp;
  17. cin >> tmp;
  18. band.push_back(tmp);
  19. }
  20. cin >> role;
  21.  
  22.  
  23. if (strF == forname && strS == surname) {
  24. cout << "Artist found" << endl;
  25. cout << forname << " " << surname << " ";
  26. ostream_iterator<string> output_iterator(cout, " ");
  27. copy(band.begin(), band.end(), output_iterator);
  28. cout<< role << endl;
  29. }
  30. }
  31. }
Success #stdin #stdout 0s 15240KB
stdin
David Byrne 1 Talking_Heads Lead-Vocals
Chris Frantz 1 Talking_Heads Drummer
Tina Weymouth 3 Talking_Heads Compass_Point_All_Stars Tom_Tom_Club Bass
stdout
Artist found
Tina Weymouth Talking_Heads Compass_Point_All_Stars Tom_Tom_Club Bass