Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main() {
- ifstream Fout("arr.txt");
- int count = 0, temp;
- while (!Fout.eof()) {
- Fout >> temp;
- count++;
- }
- Fout.seekg(0, ios::beg);
- Fout.clear();
- int count_space = 0;
- char symbol;
- while (!Fout.eof()) {
- cout << "e" << endl;
- Fout.get(symbol);
- if (symbol == ' ') {
- count_space++;
- }
- if (symbol == '\n') {
- break;
- }
- }
- Fout.seekg(0, ios::beg);
- Fout.clear();
- int x, y, i, j;
- x = count / (count_space + 1);
- y = count_space + 1;
- int** arr = new int* [x];
- for (i = 0; i < x; i++) {
- arr[i] = new int[y];
- }
- cout << count <<"\t";
- cout << count_space << "\t";
- for (i = 0; i < x; i++) {
- for (j = 0; j < y; j++) {
- Fout >> temp;
- arr[i][j] = temp;
- cout << arr[i][j] << "\t";
- }
- cout << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement