paste bin
Author
Language
C++
Plain text
Accesslog
Action script
Ada
Apache
Arduino
Armasm
Autohotkey
Awk
Bash
Basic
Brainfuck
C
Clojure
Cmake
C#
css
D
Delphi
Dockerfile
Erlang
Fortran
F#
Gauss
Go
Gradle
Graphql
Groovy
Haskell
Ini
Java
JavaScript
json
Julia
Kotlin
Lasso
LaTeX
Leaf
lisp
llvm
Lua
Makefile
Markdown
Mathematica
Matlab
Nginx
Objective-C
Ocaml
Oxygene
Perl
PgSQL
php
Powershell
Processing
Profile
Properties
Puppet
Purebasic
Python
Q
QML
R
Ruby
Rust
Scala
Scheme
Scilab
Shell
Smalltalk
SQL
Swift
Typescript
VB.NET
VB Script
Verilog
Vim
Wasm
x86asm
Xml
Xquery
Yaml
source code:
#include <cstdio> #define MAXN 50 int block[MAXN][MAXN]; void outputSquare(int W) { for(int i=0;i<W;i++) { for(int j=0;j<W;j++) { printf("%d ",block[i][j]); } printf("\n"); } } int main(void) { int N,W; scanf("%d",&N); W=2*N-1; int num = 1,i,j,next_i,next_j; i=0; j=N-1; block[i][j]=num; num++; for(num=2;num<=W*W;num++) { next_i = i-1; if(next_i<0) { next_i=W-1; } next_j = j+1; if(next_j == W) { next_j=0; } if(block[next_i][next_j]!=0) { next_i = i+1; if(next_i==W) { next_i = 0; } next_j = j; } block[next_i][next_j] = num; i = next_i; j = next_j; } outputSquare(W); return 0; }
comment: