Advertisement
socialgraph

Untitled

Jul 11th, 2020
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <fstream>
  2. #include <iostream>
  3. #include <vector>
  4. #include <iomanip>
  5.  
  6. using namespace std;
  7.  
  8. vector<string> split(const string& text, char delim) {
  9.     stringstream ss(text);
  10.     string item;
  11.     vector<string> elems;
  12.     while (getline(ss, item, delim)) {
  13.         elems.push_back(item);
  14.     }
  15.     return elems;
  16. }
  17.  
  18. int main() {
  19.     ifstream inp("1.txt");
  20.     int N;
  21.     int M;
  22.  
  23.     inp >> N;
  24.     inp >> M;
  25.     inp.ignore(1);
  26.  
  27.     while (N--) {
  28.         string line;
  29.         getline(inp, line);
  30.         for (const auto& value : split(line, ',')) {
  31.             cout << setw(10) << value;
  32.         }
  33.         cout << endl;
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement