Problem hidden
|This problem was hidden by Editorial Board member probably because it has incorrect language|version or invalid test data, or description of the problem is not clear.|

RGB7547 - Утга олголт 7

NxN хэмжээтэй квадрат массивыг жишээн дээрх загвараар дүүргэ.

Input

Квадрат массивын хэмжээ натурал тоо N өгөгдөнө. N<10.

Output

Квадрат массивын элементүүдийг мөр мөрөөр нь хэвлэнэ.

Гэхдээ элемент бүрийг 3 хоосон зайд хойш нь шахаж хэвлэнэ. Жишээг сайн ажиглана уу.

Жишээн дээрх 1-ийн тоо гэхэд урдаа, хойноо тус бүр 2 хоосон зайтай байна. Мөн 10-ын тоо урдаа 1, хойноо 2 хоосон зайтай байна.

Example

Input:
5

Output:
21 22 23 24 25
20 19 18 17 16
11 12 13 14 15
10 9 8 7 6
1 2 3 4 5

Нэмсэн:Bataa
Огноо:2013-02-07
Хугацааны хязгаарлалт:1s
Эх кодын хэмжээний хязгаарлалт:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Програмчлалын хэлүүд:ADA95 ASM32 BASH BF C NCSHARP CSHARP C++ 4.3.2 CPP C99 CLPS LISP sbcl LISP clisp D ERL FORTRAN HASK ICON ICK JAVA JS-RHINO JULIA LUA NEM NICE OCAML PAS-GPC PAS-FPC PERL PHP PIKE PRLG-swi PYTHON PYPY3 PYTHON3 RUBY SCALA SCM guile ST TCL WHITESPACE

hide comments
2023-11-29 01:27:58
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,i,j;
cin>>n;
for(i=n;i>=1;i--){
if(i%2==0){
for(j=n*i;j>=n*i-(n-1);j--){
if(j<=9){
cout<<" "<<j;
}
else{
cout<<" "<<j;
}
}
}
else{
for(j=n*i-(n-1);j<=n*i;j++){
if(j<=9){
cout<<" "<<j;
}
else{
cout<<" "<<j;
}
}
}
cout<<endl;
}
return 0;
}
2023-11-21 07:48:11
#include <iostream>
using namespace std;
int main()
{
int n, s=1,j ,i,k=1,g=1;
cin >> n;
int a[11][11];
for(i=n;i>=1;i--){
for(j=1;j<=n;j++){
if (i%2==1) k=n*(n-g)+j;
else k=i*n+1-j;
if (k>=10) cout<<" "<<k;
else cout<<" "<<k;
}
g++;
cout << endl;
}

return 0;
}
yun bolku bn?
2023-02-15 03:26:45
EZ
2022-10-24 06:35:05
#include<iostream>

using namespace std;

int main(){
long long a,b,p,n,k,s,i,j;

cin>>n;

s=n;
for(i=1; i<=n; i++){
if(i%2==0){
for(j=s*n; j>(s-1)*n; j--){
if(j>9) cout<<" "<<j<<" ";
else cout<<" "<<j<<" ";
}
} else {
for(j=n*(s-1)+1; j<=s*n; j++){
if(j>9) cout<<" "<<j<<" ";
else cout<<" "<<j<<" ";
}
}
s--;
cout<<endl;
}

return 0;
}
2022-10-12 05:49:02
#include<stdio.h>
int main(){
int i,j,n,t=1;
scanf("%d",&n);
int a[n][n];
t=n*n;
for (i=0;i<n;i++){
if(i%2!=0){
for(j=0;j<n;j++){
a[i][j]=t;
t--;
}
}
else{
for(j=n-1;j>=0;j--){
a[i][j]=t;
t--;
}

}
}for (i=0;i<n;i++){
for(j=0;j<n;j++){
printf("%3d",a[i][j]);
}
printf("\n");
}
}
2022-06-13 03:53:09
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;

class LOL xD {
public static void main(String[] args) {
Scanner intd = new Scanner(System.in);
int d,s=0,i,j;
int n = intd.nextInt();
d= n*n;
int z = n*n;
for(i = 1; i <= n ; i++ ) {
System.out.println("");
if(i % 2 == 1) {
d= d-n;
for(j = 1; j<= n; j++){
d=d+1;
System.out.print(d+" ");
}
d= d-(n*2);
}else if(i % 2 == 0) {
z= z-n;
for(j =1; j<=n; j++) {
System.out.print(z+" ");
z=z-1;
}
}
}
System.out.print("Bi hen be ? taagaarai hha");
System.out.print("Amjilt");
}
}


Last edit: 2022-06-13 03:54:35
2020-01-08 04:10:07
#include<bits/stdc++.h>

using namespace std;

int main(){
long long a,b,p,n,k,s,i,j;

cin>>n;

s=n;
for(i=1; i<=n; i++){
if(i%2==0){
for(j=s*n; j>(s-1)*n; j--){
if(j>9) cout<<" "<<j<<" ";
else cout<<" "<<j<<" ";
}
} else {
for(j=n*(s-1)+1; j<=s*n; j++){
if(j>9) cout<<" "<<j<<" ";
else cout<<" "<<j<<" ";
}
}
s--;
cout<<endl;
}

return 0;
}
2019-11-09 06:23:42


Last edit: 2019-11-09 06:24:56
2019-03-28 02:54:23
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,i,j;
signed main()
{
cin>>n;
for(i=1;i<=n;i++)
{
if(i%2==1)
{
for(j=n*n-i*n+1;j<=n*n-i*n+n;j++)
{cout<<" "; if(j/10>=1) cout<<j<<" ";
else cout<<" "<<j<<" ";} cout<<endl;
}
else
{
for(j=n*n-i*n+n;j>=n*n-i*n+1;j--)
{cout<<" "; if(j/10>=1) cout<<j<<" ";
else cout<<" "<<j<<" ";} cout<<endl;
}
}
return 0;
}
2019-02-21 11:44:39
#include<bits/stdc++.h>

using namespace std;

int main () {
int n,i,j,s;

cin>>n;

int a[n+1][n+1];

s=n*n;

for(i=1;i<=n;i++) {
for(j=1;j<=n;j++) {
if (i%2==0) {
a[i][j]=s--;

}
else a[i][n+1-j]=s--;
}
}
for(i=1;i<=n;i++) {
for(j=1;j<=n;j++) {
if((a[i][j]/10)>0) cout<<" "<<a[i][j];
else cout<<" "<<" "<<a[i][j];
if(j%n==0) cout<<endl;
}
}
}
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.