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.|

RGB7541 - Утга олголт 1

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

Input

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

Output

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

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

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

Example

Input:
5

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

Нэмсэн: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
2024-03-20 14:31:15
CHOKO IN THE HOUSE

#include <iostream>
using namespace std;
int main() {
int n;
cin>>n;
int temp = 0;
for(int i=0; i<n; i++){
if(i%2==0){
for(int j=0; j<n; j++){
if(temp<10){
temp++;
cout<<" "<<temp<<" ";
}
else{
temp++;
cout<<temp<<" ";
}
}
}
else{
cout<<endl;
temp = temp+n;
for(int j=0; j<n; j++){
if(temp<10){
cout<<" "<<temp<<" ";
temp--;
}
else {
cout<<temp<<" ";
temp--;
}
}
cout<<endl;
temp = temp+n;
}
}
return 0;
}


2024-01-29 12:29:33
#include<iostream>
using namespace std;
int main(){
int n, a;
cin >> n;
for (int i = 1; i <= n; i++){
if (i % 2 == 1){
a = (i - 1) * n + 1;
for(int j=a; j<=a+n-1; j++){
if (j < 10){
cout << " " << j;
}
else {
cout << " " << j;
}
}
}
if (i % 2 == 0){
a = i * n;
for(int j=a; j>=a-n+1; j--){
if (j < 10){
cout << " " << j;
}
else {
cout << " " << j;
}
}
}
cout << endl ;
}
}
2023-11-22 01:28:59
#include<bits/stdc++.h>
using namespace std;
int main(){
int n, i, j;
cin>>n;
int a[n][n];
for(j=1;j<=n;j++){
if(j%2!=0){
for(i=((j-1)*n+1);i<=j*n;i++){
if(i/10<1) cout<<" ";
cout<<i<<" ";
}
}
else{
for(i=n*j;i>=(n*(j-1)+1);i--){
if(i/10<1) cout<<" ";
cout<<i<<" ";
}
}
cout<<endl;
}
return 0;
}

Last edit: 2023-11-22 01:34:06
2023-11-06 16:08:35
//c++
#include <iostream>
using namespace std;
int main(){
int a;
cin>>a;
int k=1;
int p=0;
for(int i=1; i<=(a*a); i+=k){
p++;
if(i<10)
{
cout<<" "<<i;
}
else
{
cout<<' '<<i;
}
if(p==a)
{
cout<<'\n';
p-=a;
i+=a;
k=-k;
if(k==1)
{
i--;
}
else
{
i++;
}
}
}
}
2023-11-05 04:17:13
i hate utga olgolt 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
2023-05-15 13:14:59






































































































































































































































































































ИБ Н МАЧИД РАЙХТАЙ ❤️
2022-12-15 16:18:46
sdaaaa ve ynkan
2022-10-12 05:46:23
#include<stdio.h>
int main(){
int i,j,n,t=1;
scanf("%d",&n);
int a[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");
}

return 0;
}
2021-11-18 12:18:44
don`t spam here!
2021-10-25 13:29:27











































































































































































































































































































































































































































































































































































































































































..











.
.
.
.
.
.
.

.
.
.
.
.































































.
.
.
.
.
.
.
.

.

.
.
.
.
.
.
.
.
.










































































































































































© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.