13300
来源:互联网 发布:js jsonarray 遍历 编辑:程序博客网 时间:2024/06/05 14:41
Numbers GameTime Limit: 1000ms, Special Time Limit:2500ms, Memory Limit:65536KBTotal submit users: 67, Accepted users: 65Problem 13300 : No special judgementProblem description
Youngkl likes playing numbers games, but some games like Sudoku are so simple for him. And then he wants to play a more difficult game. Do you want to play with him?
Let me introduce the rules of the game for you. For each input N, you should fill in the N*N table with the numbers(from 1 to N*N) and you should always start at the diagonal from the upper left corner. Go horizontal direction first, then vertical. Here are some examples for you, please find the law in the samples and complete the numbers game.
Each line will contain one integer N (1<=N<=30).Process to end of file.
OutputFor each set of input data, output N lines of the completed form (each line of N integers, separated by a space between each number).
Sample Input34Sample Output
1 2 34 6 75 8 91 2 3 45 8 9 106 11 13 147 12 15 16Problem SourceHNU Contest
#include <stdio.h>int main(){ int n; while( scanf("%d",&n)!=EOF ) fun(n); return 0;}int fun(int n){ int Ncnt; int N[31][31]; int i,j,k; Ncnt=n*n; N[n][n]=Ncnt; for(i=n;i>0;i--) { j=n; while(j>i) { N[j][i]=Ncnt--; j--; } k=n; while(k>=i) { N[i][k]=Ncnt--; k--; } } for(i=1;i<(n+1);i++) { for(j=1;j<(n+1);j++) { printf("%d",N[i][j]); if(j!=n) printf(" "); else printf("\n"); } } return 0;}
- 13300
- c2-3-main-frm_13101-13300渲染日志
- 视频聊天 Demo
- Matlab 第一章
- Sublime Text 3操作技巧
- [其他] 上传漏洞之文本编辑器
- java 常用序列化和反序列化框架使用demo
- 13300
- CodeForces#311 C. Arthur and Table
- Android Fragment 真正的完全解析(下)
- 一个人开发手游有多难
- 黑马程序员——面向对象
- eclipse 修改背景色 插件
- android开发步步为营之68:Facebook原生广告接入总结
- CodeForces 349D Apple Tree(树形DP)
- 教育培训企业:如何优雅、机智地做邮件营销?