Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #include <algorithm>
  2. #include <vector>
  3. #include <iostream>
  4. #include <fstream>
  5. #include <string>
  6. #include <iomanip>
  7. using namespace std;
  8.  
  9. //void print_vector(vector<string> st) {
  10. //for(cons)
  11. //}
  12.  
  13. int main() {
  14. ifstream input("C:\\Users\\hrachyh\\Desktop\\f.txt");
  15. string rows, columns;
  16. getline(input, rows, ' ');
  17. int row = stoi(rows);
  18. //cout << row << endl;
  19.  
  20. getline(input, columns);
  21. int column = stoi(columns);
  22. //cout << column << endl;
  23. int alw = column;
  24. while (row != 0) {
  25. vector <string> str_vect;
  26. string stf1;
  27. while (column != 0) {
  28.  
  29. if (column == 1) {
  30. getline(input, stf1, '\n');
  31. str_vect.push_back(stf1);
  32. }
  33. else {
  34. getline(input, stf1, ',');
  35. str_vect.push_back(stf1);
  36. }
  37.  
  38. column -= 1;
  39. }
  40. str_vect.push_back("end");
  41. for (const string& a : str_vect) {
  42. if (a != "end") {
  43. cout <<' '<< setw(10) << a;
  44. }
  45. }
  46. if (row != 1) {
  47. cout << endl;
  48. }
  49.  
  50. row -= 1;
  51. column = alw;
  52. }
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement