Advertisement
193030

Other reading, first k, then two nums, and strings

Apr 3rd, 2020
503
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.47 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.     int k = 0;
  17.     cin >> k;
  18.     cin.ignore();
  19.    
  20.     while(k--)
  21.     {
  22.     stringstream stream;
  23.  
  24.     getline(cin,input);
  25.     stream.str(input);
  26.     stream >> newString;
  27.     int firstNumber = stoi(newString);
  28.     stream >> newString;
  29.     int secondNumber = stoi(newString);
  30.    
  31.  
  32.     getline(cin, input);
  33.     stream.str(input);
  34.     stream.clear();
  35.     while(stream >> newString)
  36.     {
  37.  //   stream.str(input);
  38.     while(stream >> newString)
  39.     {
  40.         nums.push_back(stoi(newString));
  41.     }
  42.  
  43.  
  44.  
  45.     getline(cin, input);
  46.     stream.str(input);
  47.     stream.clear();
  48.     while(stream >> newString)
  49.     {
  50.         nums2.push_back(stoi(newString));
  51.  
  52.     }
  53.     getline(cin, input);
  54.     stream.str(input);
  55.     stream.clear();
  56.     while(stream >> newString)
  57.     {
  58.         nums3.push_back(stoi(newString));
  59.  
  60.     }
  61.     for(int i =1; i< nums.size(); i++)
  62.  
  63.     {
  64.         cout << nums[i] << endl;
  65.     }
  66.     for(int i =1; i< nums2.size(); i++)
  67.  
  68.     {
  69.         cout << nums2[i] << endl;
  70.     }
  71.     for(int i =1; i< nums3.size(); i++)
  72.  
  73.     {
  74.         cout << nums3[i] << endl;
  75.     }
  76.     }
  77.     cout << "The first number is: " << firstNumber << " The second number is: " << secondNumber << endl;
  78.  
  79.     }
  80.  
  81.  
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement