Advertisement
Nikita051

Untitled

Jan 24th, 2023
1,038
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. int main() {
  6.     ifstream Fout("arr.txt");
  7.     int count = 0, temp;
  8.     while (!Fout.eof()) {
  9.         Fout >> temp;
  10.         count++;
  11.     }
  12.    
  13.     Fout.seekg(0, ios::beg);
  14.     Fout.clear();
  15.  
  16.     int count_space = 0;
  17.     char symbol;
  18.     while (!Fout.eof()) {
  19.         cout << "e" << endl;
  20.         Fout.get(symbol);
  21.         if (symbol == ' ') {
  22.             count_space++;
  23.         }
  24.         if (symbol == '\n') {
  25.             break;
  26.         }
  27.     }
  28.     Fout.seekg(0, ios::beg);
  29.     Fout.clear();
  30.  
  31.     int x, y, i, j;
  32.     x = count / (count_space + 1);
  33.     y = count_space + 1;
  34.     int** arr = new int* [x];
  35.     for (i = 0; i < x; i++) {
  36.         arr[i] = new int[y];
  37.     }
  38.     cout << count <<"\t";
  39.     cout << count_space << "\t";
  40.     for (i = 0; i < x; i++) {
  41.         for (j = 0; j < y; j++) {
  42.             Fout >> temp;
  43.             arr[i][j] = temp;
  44.             cout << arr[i][j] << "\t";
  45.         }
  46.         cout << endl;
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement