193030

While, sstream, 2 vectors[ ]

Apr 3rd, 2020
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <string.h>
  4. #include <vector>
  5. #include <sstream>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.     string newString, input;
  12.     vector <int> nums(1);
  13.     vector <int> nums2(1);
  14.     vector <int> nums3(1);
  15.  
  16.     while(getline(cin, input))
  17.     {
  18.     stringstream stream;
  19.     stream.str(input);
  20.     while(stream >> newString)
  21.     {
  22.         nums.push_back(stoi(newString));
  23.     }
  24.  
  25.  
  26.  
  27.     getline(cin, input);
  28.     stream.str(input);
  29.     stream.clear();
  30.     while(stream >> newString)
  31.     {
  32.         nums2.push_back(stoi(newString));
  33.  
  34.     }
  35.     getline(cin, input);
  36.     stream.str(input);
  37.     stream.clear();
  38.     while(stream >> newString)
  39.     {
  40.         nums3.push_back(stoi(newString));
  41.  
  42.     }
  43.     for(int i =1; i< nums.size(); i++)
  44.  
  45.     {
  46.         cout << nums[i] << endl;
  47.     }
  48.     for(int i =1; i< nums2.size(); i++)
  49.  
  50.     {
  51.         cout << nums2[i] << endl;
  52.     }
  53.     for(int i =1; i< nums3.size(); i++)
  54.  
  55.     {
  56.         cout << nums3[i] << endl;
  57.     }
  58.     }
  59.  
  60.  
  61.  
  62.  
  63. }
Add Comment
Please, Sign In to add comment