1 条题解
-
0
C :
#include<stdio.h> void main() { int n; scanf("%d",&n); int a;//hang上半部分 for(a=1;a<=(n+1)/2;a++){ int b;//kongge for(b=1;b<=a-1;b++){ printf(" "); } int c; for(c=1;c<=n;c++){ printf("*"); } printf("\n"); } //下半部分 int d; for(d=1;d<=n/2;d++){ int e=1;//kongge for(;e<=n/2-d;e++){ printf(" "); } int c; for(c=1;c<=n;c++){ printf("*"); } printf("\n"); } }
C++ :
#include <iostream> #include <cstring> using namespace std; int main(){ int i,j,n,t; cin>>n; t = n / 2 + 1; for(i = 1;i <= t;i++){ for(j = 1;j <= i - 1;j++){ cout<<" "; } for(j = 1;j <= n;j++){ cout<<"*"; } cout<<endl; } for(i = t - 1;i >= 1;i--){ for(j = 1;j <= i - 1;j++){ cout<<" "; } for(j = 1;j <= n;j++){ cout<<"*"; } cout<<endl; } }
Python :
n = int(input()) for i in range(0, n): if(i < n - 2): print(" " * i, end="") print("*" * n) else: print(" " * (n - i - 1), end="") print("*" * n)
- 1
信息
- ID
- 2151
- 时间
- 1000ms
- 内存
- 16MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者