Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Rijoanul Hasan
- * Timus 1319. Hotel
- * C++
- */
- #include <cstdio>
- #include <algorithm>
- #include <string>
- #include <iostream>
- #include <cstdlib>
- #include <vector>
- using namespace std;
- int main()
- {
- int n;
- while(cin >> n)
- {
- int array[n][n];
- int i, j, k, value = 0;
- for(i = n-1; i >= 0; i--)
- {
- k = 0;
- for(j = i; j < n; j++)
- {
- array[k++][j] = ++value;
- //cout << k-1 << j << ' ' << value << endl;
- }
- }
- for(i = n-1; i >= 0; i--)
- {
- k = n-i;
- for(j = 0; j < i; j++)
- {
- array[k++][j] = ++value;
- //cout << k-1 << j << ' ' << value << endl;
- }
- }
- for(i = 0; i < n; i++)
- {
- for(j = 0; j < n; j++)
- {
- cout << array[i][j];
- if(j != n) cout << ' ';
- }
- cout << endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement