Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <sstream>
- #include <queue>
- #include <cstring>
- #include <iostream>
- #include <string>
- using namespace std;
- struct ST {
- string name;
- string phone ;
- };
- void rfile(queue<ST> &q, string path) {
- ifstream inf(path);
- ST t;
- stringstream ss;
- queue<ST> АТС2;
- queue<ST> АТС3;
- queue<ST> АТС_mo;
- string st;
- while (getline(inf, st)) {
- ss << st;
- ss >> t.name;
- ss >> t.phone;
- if (t.phone[0] != '2'){
- АТС2.push(t);
- } else if (t.phone[0] == '3'){
- АТС3.push(t);
- } else {
- АТС_mo.push(t);
- }
- ss.clear();
- }
- while (!АТС2.empty()) {
- q.push(АТС2.front());
- АТС2.pop();
- }
- while (!АТС3.empty()) {
- q.push(АТС3.front());
- АТС3.pop();
- }
- while (!АТС_mo.empty()) {
- q.push(АТС_mo.front());
- АТС_mo.pop();
- }
- }
- void p(queue<ST> q) {
- while (!q.empty()) {
- cout << q.front().name << " - " << q.front().phone << endl << endl;
- q.pop();
- }
- }
- int main() {
- queue<ST> g;
- rfile(g, "..\\tr.txt");
- p(g);
- }
Advertisement
Add Comment
Please, Sign In to add comment