C语言实验——for循环打印图形(循环结构)(sdut oj)
2017-01-25 17:41
686 查看
C语言实验——for循环打印图形(循环结构)
Time Limit: 1000MS Memory Limit: 65536KB
Problem Description
通过使用双重for循环语句,打印下列图形:
Input
Output
Example Input
Example Output
* *** ***** ******* ***** *** *
Hint
Author
参考代码
#include<stdio.h> int main() { int n; int i; int temp; n = 4; for(i = 1; i <= n; i++) { for(temp = i; temp < n; temp++) { printf(" "); } for(temp = i; temp > 0; temp--) { printf("*"); } for(temp = i - 1; temp >0; temp--) { printf("*"); } printf("\n"); } for(i = n - 1; i > 0; i--) { for(temp = i; temp < n; temp++) { printf(" "); } for(temp = i; temp > 0; temp--) { printf("*"); } for(temp = i - 1; temp > 0; temp--) { printf("*"); } printf("\n"); } return 0; }
相关文章推荐
- C语言实验——for循环打印图形(循环结构)
- oj期中测验--C语言实验——for循环打印图形(循环结构)(1954)
- 1121 C语言实验——for循环打印图形(循环结构)
- C语言实验——for循环打印图形(循环结构)
- Problem J: C语言实验——for循环打印图形(循环结构)
- oj1954: C语言实验——for循环打印图形(循环结构)
- 山东理工大学ACM平台题答案 1121 C语言实验——for循环打印图形(循环结构
- C语言实验——打印图形 (sdut oj)
- C语言实验——for循环打印图形(循环结构)
- OJ循环——for循环打印图形
- C语言实验——打印数字图形 (sdut oj)
- for循环打印图形(循环结构)
- C语言中用循环打印各种图形
- C语言实验——求阶乘(循环结构)
- C语言实验——求阶乘(循环结构)
- C语言实验——计算1到n的和(循环结构)
- C语言实验——打印图形
- 分别用for循环和while循环实现打印金字塔图形
- C语言实验——打印数字图形
- 控制结构之循环:解决打印图形问题