Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int** getArray(int &r, int &c)
- {
- string st;
- char s[50];
- int** arResult;
- int* bufRow;
- int buf, k, j, y, x=2;
- unsigned int rows, columns;
- ifstream input("in.txt", ios::in);
- if (input.bad())
- return NULL;
- input >> rows;
- input >> columns;
- input.close();
- if (input.eof())
- return NULL;
- arResult = new int*[rows];
- for (int i = 0; i < rows; i++)
- {
- ifstream input("in.txt", ios::in);
- for(y=0;y<x;y++)
- getline (input,st);
- bufRow = new int[columns];
- k=0;
- cout << st.length()<< endl << endl;;
- for(j=0; j< st.length(); j++)
- {
- s[k]=st[j];
- cout << s[k];
- if(isdigit(s[k]))
- {
- k++;
- }
- input >> s[k];
- }
- cout << endl;
- for (j = 0; j < columns; j++)
- {
- if (!(isdigit(s[j])))
- {
- bufRow = NULL;
- }
- else
- {
- bufRow[j] = s[j]-'0';
- }
- }
- if (bufRow == NULL)
- {
- rows = i;
- break;
- }
- arResult[i] = bufRow;
- x++;
- input.close();
- }
- r = rows;
- c = columns;
- return arResult;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement