1 条题解

  • 0
    @ 2022-12-9 0:58:45

    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",i+64); 
    		} 
    		
    		//负责换行
    		printf("\n"); 
    		
    	}
    
    	return 0; 
    } 
    

    C++ :

    #include <iostream>
    using namespace std;
    
    int main(){ 
    	int i,j,n;
    	char c='A';
    	cin>>n;
    	for(i = 1;i <= n;i++){	
    		for(j = 1;j <= n - i;j++){
    			cout<<" ";
    		} 		
    		for(j = 1;j <= 2 * i - 1;j++){
    			cout<<c;
    		} 	
    		cout<<endl;
    		(char)(c++);
    	} 	 
    }
    
    

    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(i),end="")
            j=j+1
        i=i+1
        print()
    
    • 1

    信息

    ID
    130
    时间
    1000ms
    内存
    16MiB
    难度
    10
    标签
    递交数
    2
    已通过
    2
    上传者