Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <iomanip>
  5. #include <vector>
  6. #include <sstream>
  7.  
  8. using namespace std;
  9.  
  10. void printRow(vector<int>& row) {
  11. if (row.empty())
  12. return;
  13.  
  14. for (const auto& e : row) {
  15. // cout << setfill('.');
  16.  
  17. if (e != -1)
  18. cout << setw(10) << e;
  19. cout << ' ';
  20. }
  21. }
  22.  
  23. int main() {
  24. ifstream input("input.txt");
  25.  
  26. int n;
  27. int m;
  28. string st1;
  29.  
  30. input >> n;
  31. input >> m;
  32. getline(input, st1);
  33.  
  34. while (n > 0) {
  35. vector<int> values;
  36. string in;
  37. getline(input, in);
  38. stringstream ss(in);
  39. string v;
  40. int m_copy = m;
  41. while (m_copy > 0) {
  42. getline(ss, v, ',');
  43. values.push_back(atoi(v.c_str()));
  44. m_copy--;
  45. }
  46. values.push_back(-1);
  47. printRow(values);
  48. if (n > 1)
  49. cout << endl;
  50. n--;
  51. }
  52.  
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement