1 solutions
-
2
题目大意:
输入一个正整数 ,生成一个层数为 的金字塔:
⬆️详细见题目⬆️ 下载图片

我们不难看出: 1、TA是由 “/ ” 、 "__" 和 "\ " 组成的。
2、第 行由 - 个空格 、 个 “/” 、 个 “_” 与 个 "\ " 组成。
AC code:
#include <bits/stdc++.h> using namespace std; int n; int main() { cin>>n; /* 每行空格 n-i; */ for(int i = 1;i<= n;i++){ for(int j = 1;j<n-i+1;j++){ cout<<" "; } cout<<"/"; for(int j = 0;j<(i-1)*2;j++){ cout<<"_"; } printf("%c\n",92); } return 0; }
Information
- ID
- 264
- Time
- 1000ms
- Memory
- 64MiB
- Difficulty
- 6
- Tags
- # Submissions
- 274
- Accepted
- 78
- Uploaded By