two
来源:互联网 发布:linux关闭mysql启动 编辑:程序博客网 时间:2024/04/28 14:53
题目:<br/>跟蛇形填数一样,只是填数要求按照三角形填。注意每组数据之间用空行隔开<br>
个人理解:<br>主要还是应当知道每个方向数的增长是不变的即可<br/>
#include<stdio.h>int a[1000][1000];int main(){ int n,count,x,y,m,i,j,l; int b[1000];scanf("%d",&m);if(m<=0)return 0; count=a[x=0][y=0]=1; for(i=0;i<m;i++) scanf("%d",&b[i]); printf("\n");for(i=0;i<m;i++){ n=b[i]; while(count<((n+1)*n)/2){ while(y+1<n && !a[x][y+1]) a[x][++y]=++count; while(y-1>=0 &&!a[x+1][y-1]&&x+1<n) a[++x][--y]=++count; while(x-1<n &&!a[x-1][y]) a[--x][y]=++count; } for(x=0;x<n;x++){ //输出 for(y=0;y<n-x;y++){ printf("%-3d ",a[x][y]); } printf("\n"); } printf("\n"); for(l=0;l<1000;l++) {//初始化为0 for(j=0;j<1000;j++){ a[l][j]=0; }} count=a[x=0][y=0]=1;} return 0; }
阅读全文
0 0
- two:
- two
- two
- Two
- two
- two
- Two
- TWO
- two
- two and two and two two...
- HackRank Two Two
- Two Brothers
- css two
- Function Two
- two years
- Two Ends
- Two Strings
- Two Sum
- java内部类
- 【Unity】Unity自带卡通shader(toon shader)分析(一)
- Android_Fragment碎片
- 机器学习工程实践方法论
- Kotlin-08.类和继承(class/Inheritance)
- two
- java基础
- Maven<打包Scala程序打不进class文件和依赖的解决办法>
- java相对路径读取文件
- hql投影查询之—— [Ljava.lang.Object; cannot be cast to cn.bdqn.guanMingSys.entity.Notice
- qduoj 冰清玉洁丶YCB(水题)
- OKGO 最基础post请求使用
- PAT乙级真题及训练集(10)--1041. 考试座位号(15)
- 文件操作