1 solutions
-
0
C :
#include<stdio.h> int main(){ int n,i,j,z; scanf("%d",&n); //负责行 for(i = 1;i <= n;i++){ //负责空格 for(j = 1;j <= n - i;j++){ printf(" "); } //负责打印数字 for(z=1;z <= 2 * i - 1;z++){ printf("%c",z+64); } //负责换行 printf("\n"); } return 0; }
C++ :
#include<iostream> using namespace std; int main(){ int i,j,n; char c; cin>>n; for(i=1;i<=n;i++){ for(j=1;j<=n-i;j++){ cout<<" "; } for(j=1;j<=2*i-1;j++){ c=j+64; cout<<c; } cout<<endl; } }
Python :
n=int(input()) i=65 while i<n+65: j=0 k=0 while k<n+64-i: print(" ",end="") k=k+1 while j<(i-65)*2+1: print(chr(j+65),end="") j=j+1 i=i+1 print()
- 1
Information
- ID
- 10874
- Time
- 1000ms
- Memory
- 16MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By