Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- 5 4 3 2 1
- 4 3 2 1 2
- 3 2 1 2 3
- 2 1 2 3 4
- 1 2 3 4 5
- */
- //VAR I
- #include <iostream>
- using namespace std;
- int main() {
- int n,a[100][100];
- cin>>n;
- for(int i=1;i<=n;i++){
- for(int j=1;j<=n;j++){
- a[i][j]=abs((n+1)-(i+j))+1;
- }
- cout<<endl;
- }
- for(int i=1;i<=n;i++){
- for(int j=1;j<=n;j++){
- cout<<a[i][j]<<" ";
- }
- cout<<endl;
- }
- return 0;
- }
- //VAR II
- #include <iostream>
- using namespace std;
- int main() {
- int a[100][100],n;
- cin>>n;
- for(int i=1;i<=n;i++){
- for(int j=1;j<=n;j++){
- if(i+j==n+1){
- a[i][j]=1;
- }
- else {
- if(i+j<n+1){
- a[i][j]=n-i-j+1+1;
- a[n-i+1][n-j+1]=a[i][j];
- }
- }
- }
- }
- for(int i=1;i<=n;i++){
- for(int j=1;j<=n;j++){
- cout<<a[i][j]<<" ";
- }
- cout<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement