打印杨辉三角
来源:互联网 发布:淘宝生意参谋手机版 编辑:程序博客网 时间:2024/05/18 08:15
输入杨辉三角形的层数,打印杨辉三角形
【输入形式】
6
【输出形式】
11 11 2 11 3 3 11 4 6 4 11 5 10 10 5 1
#include<iostream>#include<iomanip>using namespace std;int main(){int n,i,j;cin>>n;int z[n][n];for(i=0;i<n;i++) z[i][0]=1;for(i=0;i<n;i++) z[i][i]=1;for(i=2;i<n;i++){for(j=1;j<i;j++){z[i][j]=z[i-1][j]+z[i-1][j-1];}}for(i=0;i<n;i++){ for(j=0;j<=i;j++) cout<<fixed<<setw(4)<<left<<setfill(' ')<<z[i][j]; cout<<endl;} return 0; }
阅读全文
0 0
- 打印杨辉三角
- 打印杨辉三角
- 打印杨辉三角
- 打印杨辉三角
- 打印杨辉三角
- 打印杨辉三角
- 打印杨辉三角
- 打印杨辉三角
- 打印-杨辉三角
- 打印杨辉三角
- 打印杨辉三角
- 打印杨辉三角
- 打印杨辉三角
- 杨辉三角打印
- 打印杨辉三角
- 杨辉三角打印
- 打印杨辉三角
- 打印杨辉三角
- FL Studio浏览器菜单你了解多少?
- 交换排序:起泡排序、快速排序
- Understanding Machine Learning —— pdf下载
- JNI开发实践-小技巧
- 使用HTML5 select标签来实现更改网页背景颜色
- 打印杨辉三角
- 数据库基础
- 解决Tomcat catalina.out 不断成长导致档案过大的问题
- Qt信号的槽
- 开源协议-GPL、BSD、MIT、Mozilla、Apache和LGPL 之间的区别
- 表格 td 长度的问题
- c++ boost 库中提供的share_ptr(智能指针)
- MD5加密解密
- debug调试jdk源码