Created
May 26, 2011 16:24
-
-
Save janisozaur/993469 to your computer and use it in GitHub Desktop.
diagonal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <iomanip> | |
#include <vector> | |
#include <cmath> | |
#include <fstream> | |
using namespace std; | |
int main(int argc, char *argv[]) | |
{ | |
int n; | |
vector<int> m; | |
ifstream file; | |
file.open("i2", ifstream::in); | |
if (!file.is_open()) { | |
cerr << "error" << endl; | |
return 1; | |
} | |
while (file) { | |
file >> n; | |
m.push_back(n); | |
} | |
int a = sqrt(m.size()); | |
for (int i = 0; i < a; i++) { | |
for (int j = i; j < a; j++) { | |
cout << setw(3) << m.at(i * a + j); | |
} | |
cout << endl; | |
} | |
file.close(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment