杭电2032杨辉三角
来源:互联网 发布:js button 隐藏 编辑:程序博客网 时间:2024/04/29 03:13
/*做完此题虽然对于有些人来说水题一道但是想说的是为了推杨辉三角我用了两个小时而且是比赛中所以留作纪念*/
只做思路解说因为这题对编程能力要求低主要是推算能力,注意 两边都是1,中间 加2
#include <iostream>#include <cstring>#include <cstdio>#include <algorithm>using namespace std;int n[1010];int main(){ int i, m, a=1, x, num, k, h, p, q, r, s; while(scanf("%d", &m) != EOF){ x = 0; r = 1; i = 0; num = 0; p = 2; q = 1; while(x != m){ n[i] = 1; if(x >= 2){ h = i; k = x-1; while(k){ n[h+1] = n[h-p] + n[h-q]; h++; k--; } p++; q++; } i = i + x; n[i] = 1; x++; i++; } while( r != m+1 ){ s = r; while(s){ cout<<n[num]; if(s>1) cout<<" "; num++; s--; } cout<<endl; r++; } cout<<endl; } return 0;}
/*本想注释一下但是发现看了看主要是对数学知识的运用*/
1 0
- 杭电ACM 2032 杨辉三角
- 杭电ACM 2032 杨辉三角
- 杭电 2032 杨辉三角
- 杭电ACM 2032 杨辉三角
- 杭电2032 杨辉三角
- 杭电2032杨辉三角
- 杭电ACM 2032:杨辉三角
- 杭电 2032 杨辉三角
- 【杭电】[2032]杨辉三角
- 杭电oj 2032 杨辉三角
- 【杭电-oj】-2032-杨辉三角
- 杭电2032 杨辉三角
- 杭电2032杨辉三角
- 杭电 2032 杨辉三角
- 杭电2032(杨辉三角)
- 杭电 2032 ( 杨辉三角 ) java
- 杭电 2032 杨辉三角
- 杨辉三角 杭电2032
- 2016.7.29终于弄清楚的static关键字
- 如何去掉系统ActionBar
- Java类加载器
- 解析 IllegalStateException--"Fragment already active"
- poj3126
- 杭电2032杨辉三角
- 华为2012实验室无线通信领域的首席专家朱佩英博士
- Android之AsynTask
- java-jsp--mysql中文乱码
- tjut 4647
- Spring的ApplicationEvent和ApplicationListener
- Jni调试环境搭建
- 部署spring boot应用
- 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件