C语言实验——打印金字塔 (sdut oj)
来源:互联网 发布:av淘宝网址获取网站 编辑:程序博客网 时间:2024/05/20 23:35
C语言实验——打印金字塔
Time Limit: 1000MS Memory Limit: 65536KB
Problem Description
输入n值,打印下列形状的金字塔,其中n代表金字塔的层数。
Input
输入只有一个正整数n。
Output
打印金字塔图形,其中每个数字之间有一个空格。
Example Input
3
Example Output
1 1 2 11 2 3 2 1
Hint
Author
参考代码
#include<stdio.h>int main(){ int n; int i; int c; int temp; scanf("%d",&n); for(i = 1; i <= n; i++) { for(temp = i; temp < n; temp++) { printf(" "); } for(c = 1; c <= i; c++) { if(i == 1) { printf("%d",c); } else printf("%d ",c); } for(c = i - 1; c > 0; c--) { if(c == 1) { printf("%d",c); } else printf("%d ",c); } printf("\n"); } return 0;}
0 0
- C语言实验——打印金字塔 (sdut oj)
- SDUT-1195 C语言实验——打印金字塔
- C语言实验——打印图形 (sdut oj)
- C语言实验——打印数字图形 (sdut oj)
- C语言实验——打印菱形 (sdut oj)
- C语言实验——打印金字塔
- C语言实验——打印金字塔
- C语言实验——打印金字塔
- C语言实验——for循环打印图形(循环结构)(sdut oj)
- 1195C语言实验——打印金字塔
- oj2016: C语言实验——打印金字塔
- C语言实验-打印金字塔
- C语言实验——输出字符串(sdut oj)
- C语言实验——逆置正整数 (sdut oj)
- C语言实验——买糖果 (sdut oj)
- C语言实验——圆柱体计算 (sdut oj)
- C语言实验——温度转换 (sdut oj)
- C语言实验——时间间隔 (sdut oj)
- C语言实验——for循环打印图形(循环结构)(sdut oj)
- 分治法求最大最小值
- 下载jar包,并手动安装到本地仓库
- codeforces-760-B Frodo and pillows(二分+数学)
- Activity的生命周期和模式
- C语言实验——打印金字塔 (sdut oj)
- hdu 1097
- 【转老圃无蔓】Archlinux下vim的个人配置与使用
- storage与cookie的相同点和区别
- Oracle日期类型转换格式
- JAVA 多态与动态绑定
- 走近三星全球发布会 为确保未来产品安全做了哪些措施?
- 鸡年春联
- 使用LeakCanary源代码检测内存泄漏