Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef unsigned long long ll;
- int main() {
- cin.tie(0);
- ios_base::sync_with_stdio(0);
- int t;
- cin >> t;
- for (int ti = 0; ti < t; ti++) {
- if (ti != 0) { cout << "\n"; }
- int n;
- cin >> n;
- vector<vector<ll>> mat (n, vector<ll>(n));
- vector<int> col (n);
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- ll x;
- cin >> x;
- x *= x;
- mat[i][j] = x;
- int k = 0;
- while (x) { x /= 10; k++; }
- col[j] = max(col[j], max(k, 1));
- }
- }
- cout << "Quadrado da matriz #" << ti+4 << ":\n";
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- if (j != 0) { cout << " "; }
- cout << setw(col[j]) << mat[i][j];
- }
- cout << "\n";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement