1 条题解
-
0
C :
#include<stdio.h> main() { int n; while(scanf("%d",&n)!=EOF) { for(int i=0;i<n;i++) { for(int j=1;j<=n+i;j++) { if(j<n-i) printf(" "); else printf("*"); } printf("\n"); } } }
C++ :
#include <iostream> int main() { using namespace std; char star = '*'; int height, weight; while (cin >> height){ weight = (2 * height - 1) / 2; for (int i = 1; i <= height; i++){ for (int j = 1; j <= weight; j++) cout << " "; for (int j = 1; j <= 2*i-1; j++) cout << star; cout << endl; weight--; } } }
- 1
信息
- ID
- 1513
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者