x2311

Untitled

Jun 8th, 2022
446
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <sstream>
  4. #include <queue>
  5.  
  6. using namespace std;
  7. //1 2 3 4 8 0 19 328 11 3222
  8. struct namber {
  9.     int nam;
  10. };
  11.  
  12. int main() {
  13.     queue<namber> students_info;
  14.  
  15.     int a=4;
  16.     cout << "A: ";
  17.     cin >> a;
  18.     int b=20;
  19.     cout << "B: ";
  20.     cin >> b;
  21.  
  22.     queue<namber> t1;
  23.     queue<namber> t2;
  24.     queue<namber> t3;
  25.  
  26.     ifstream info("..\\tess.txt");
  27.     string line;
  28.     namber tt;
  29.     stringstream ss;
  30.  
  31.     while (getline(info, line)) {
  32.         ss << line;
  33.         ss >> tt.nam;
  34.         if (tt.nam <= a) {
  35.             t1.push(tt);
  36.         } else if (tt.nam > a && tt.nam <= b) {
  37.             t2.push(tt);
  38.         } else {
  39.             t3.push(tt);
  40.         }
  41.         ss.clear();
  42.     }
  43.  
  44.     while (!t1.empty()) {
  45.         cout << t1.front().nam << " ";
  46.         t1.pop();
  47.     }
  48.     while (!t2.empty()) {
  49.         cout << t2.front().nam << " ";
  50.         t2.pop();
  51.     }
  52.     while (!t3.empty()) {
  53.         cout << t3.front().nam << " ";
  54.         t3.pop();
  55.     }
  56.  
  57. }
  58.  
  59.  
  60.  
  61.  
Advertisement
Add Comment
Please, Sign In to add comment