-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5.cpp
More file actions
51 lines (43 loc) · 719 Bytes
/
5.cpp
File metadata and controls
51 lines (43 loc) · 719 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
int main()
{
char cinput;
int value=0;
int i = 0;
int size = -1;
vector<int> matrix;
for( ; ; i++)
{
cin.get(cinput);
if(cinput>='0' && cinput<='9')
value = value*10 + (cinput - '0');
else if(cinput == ' ')
{
matrix.push_back(value);
value = 0;
}
else if(cinput == '\n')
{
matrix.push_back(value);
value = 0;
if(size == -1)
size = matrix.size();
else if(size * size == matrix.size())
break;
}
}
size = sqrt(matrix.size());
for(i=0; i<size; i++)
{
for(int j=0; j<matrix.size(); j+=size)
{
cout << matrix.at(i+j) << " ";
}
cout << endl;
}
return 0;
}