10 solutions

  • 1
    @ 2026-11-1 11:28:43

    史上最简单的做法!!!点赞的是彭于晏

    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int a;
        cin>>a;
        if(a==1)
        {
            cout<<"*";
        }
        else if(a==2)
    	{
    		cout<<" "<<"*"<<endl<<"*"<<"*"<<"*";
    	}
        else if(a==3)
    	{
    		cout<<" "<<" "<<"*"<<endl<<" "<<"*"<<"*"<<"*"<<endl<<"*"<<"*"<<"*"<<"*"<<"*";
    	}
    	else if(a==4)
    	{
    		cout<<" "<<" "<<" "<<"*"<<endl<<" "<<" "<<"*"<<"*"<<"*"<<endl<<" "<<"*"<<"*"<<"*"<<"*"<<"*"<<endl<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*";
    	}
    	else if(a==5)
    	{
    		cout<<" "<<" "<<" "<<" "<<"*"<<endl<<" "<<" "<<" "<<"*"<<"*"<<"*"<<endl<<" "<<" "<<"*"<<"*"<<"*"<<"*"<<"*"<<endl<<" "<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<endl<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*";
        }
        else if(a==6)
    	{
    		cout<<" "<<" "<<" "<<" "<<" "<<"*"<<endl<<" "<<" "<<" "<<" "<<"*"<<"*"<<"*"<<endl<<" "<<" "<<" "<<"*"<<"*"<<"*"<<"*"<<"*"<<endl<<" "<<" "<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<endl<<" "<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<endl<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*";
        }
        else if(a==7)
    	{
    		cout<<" "<<" "<<" "<<" "<<" "<<" "<<"*"<<endl<<" "<<" "<<" "<<" "<<" "<<"*"<<"*"<<"*"<<endl<<" "<<" "<<" "<<" "<<"*"<<"*"<<"*"<<"*"<<"*"<<endl<<" "<<" "<<" "<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<endl<<" "<<" "<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<endl<<" "<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<endl<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*";
        }
        else if(a==8)
    	{
    		cout<<" "<<" "<<" "<<" "<<" "<<" "<<" "<<"*"<<endl<<" "<<" "<<" "<<" "<<" "<<" "<<"*"<<"*"<<"*"<<endl<<" "<<" "<<" "<<" "<<" "<<"*"<<"*"<<"*"<<"*"<<"*"<<endl<<" "<<" "<<" "<<" "<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<endl<<" "<<" "<<" "<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<endl<<" "<<" "<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<endl<<" "<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<endl<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*";
        }
        else if(a==9)
    	{
    		cout<<" "<<" "<<" "<<" "<<" "<<" "<<" "<<" "<<"*"<<endl<<" "<<" "<<" "<<" "<<" "<<" "<<" "<<"*"<<"*"<<"*"<<endl<<" "<<" "<<" "<<" "<<" "<<" "<<"*"<<"*"<<"*"<<"*"<<"*"<<endl<<" "<<" "<<" "<<" "<<" "<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<endl<<" "<<" "<<" "<<" "<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<endl<<" "<<" "<<" "<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<endl<<" "<<" "<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<endl<<" "<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<endl<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*";
        }
        else if(a==10)
    	{
    		cout<<" "<<" "<<" "<<" "<<" "<<" "<<" "<<" "<<" "<<"*"<<endl<<" "<<" "<<" "<<" "<<" "<<" "<<" "<<" "<<"*"<<"*"<<"*"<<endl<<" "<<" "<<" "<<" "<<" "<<" "<<" "<<"*"<<"*"<<"*"<<"*"<<"*"<<endl<<" "<<" "<<" "<<" "<<" "<<" "<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<endl<<" "<<" "<<" "<<" "<<" "<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<endl<<" "<<" "<<" "<<" "<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<endl<<" "<<" "<<" "<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<endl<<" "<<" "<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<endl<<" "<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<endl<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*"<<"*";
        }
    	return 0;
    }
    

    Information

    ID
    68
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    1
    Tags
    (None)
    # Submissions
    190
    Accepted
    89
    Uploaded By