7 条题解

  • 4
    @ 2022-1-12 11:42:45
    #include<stdio.h>
    #include<iostream>
    #include<math.h>
    using namespace std;
    int main()
    {
    	int n;
    	cin>>n;
    	for(int i=1;i<=n+1;i++)
    	{
    		for(int j=1;j<=n*2+1;j++)
    		{
    			if(n-i+2==j||n+i==j)
    			{
    				cout<<"*";
    			}
    			else
    			{
    				cout<<" ";
    			}
    		}
    		cout<<endl;
    	}
    	for(int i=n;i>=1;i--)
    	{
    		for(int j=1;j<=n*2+1;j++)
    		{
    			if(n-i+2==j||n+i==j)
    			{
    				cout<<"*";
    			}
    			else
    			{
    				cout<<" ";
    			}
    		}
    		cout<<endl;
    	}
    }
    
    • 0
      @ 2024-11-18 22:03:57
      #include <bits/stdc++.h>
      using namespace std;
      int n,sum;
      int main()
      {
      	cin>>n;
      	for(int i=0;i<n+1;i++){
      	for(int j=1;j<=n-i;j++)cout<<" ";
      	cout<<"*";
      	if(i!=0){
      	for(int j=1;j<=i+sum;j++)cout<<" ";
      	cout<<"*";
      	sum++;
      		}
      	cout<<endl;
      	}
      	sum = n-2;
      	for(int i=1;i<=n;i++){
      	for(int j=1;j<=i;j++)cout<<" ";
      	cout<<"*";
      	if(i!=n){
      	for(int j=1;j<=n-i+sum;j++)cout<<" ";
      	cout<<"*";
      	sum--;
      		}
      	cout<<endl;
      	}
      	return 0;
      }
      
      • 0
        @ 2023-12-12 17:42:03
        /*
           *
          * *
         *   *
        *     *
         *   *
          * *
           *  
        
        */
        
        #include <iostream>
        using namespace std;
        const int INF = 0x3f3f3f3f;
        const int N = 1e5 + 10;
        
        int n; 
        
        int main()
        {
        	cin >> n;
        	
        	//首行 
        	for(int i = 1; i <= n; i++)
        		cout << " ";
        	cout << "*" << endl;
        	//上半部分
        	for(int i = 1; i <= n; i++)
        	{
        		//空格 
        		for(int j = 1; j <= n - i; j++)
        			cout << " ";
        		cout << "*";
        		//中间空格 
        		for(int j = 1; j <= 2 * i - 1; j++) 
        			cout << " ";
        		cout << "*" << endl; 
        	} 
        	//下半部分 
        	for(int i = 1; i <= n - 1; i++)
        	{
        		//空格
        		for(int j = 1; j <= i; j++)
        			cout << " ";
        		cout << "*";
        		//中间空格
        		for(int j = 1; j <= 2 * n - 1 - 2 * i; j++)
        			cout << " ";
        		cout << "*" << endl;
        	}
        	//最后一行 
        	for(int i = 1; i <= n; i++)
        		cout << " ";
        	cout << "*" << endl;
            return 0;
        }
        
        
        • -3
          @ 2022-1-12 11:42:48
          #include <math.h>
          #include <stack>
          #include <stdio.h>
          #include <iostream>
          #include <vector>
          #include <iomanip>
          #include <string.h>
          #include <algorithm>
          using namespace std;
          #define LL long long
          const int N = 1e5 + 10;
          const int INF = 0x3f3f3f3f;
          int main()   
          {
          	int n;
          	cin >> n;
          	for(int i = 1 ; i <= n + 1 ; i++)
          	{
          		for(int j = 1 ; j <= n * 2 + 1 ; j++)
          		{
          			if(n - i + 2 == j || n + i==j)
          				cout << "*";
          			else
          			    cout << " ";
          		}
          		cout << endl;
          	}
          	for(int i = n ; i >= 1 ; i--)
          	{
          		for(int j = 1 ; j <= n * 2 + 1 ; j++)
          		{
          			if(n - i + 2 == j || n + i == j)
          				cout << "*";
          			else
          				cout << " ";
          		}
          		cout << endl;
          	}
          }
          
          • -4
            @ 2022-2-11 9:23:26

            #include<stdio.h> #include<iostream> #include<math.h> using namespace std; int main() { int n; cin>>n; for(int i=1;i<=n+1;i++) { for(int j=1;j<=n2+1;j++) { if(n-i+2j||n+ij) { cout<<""; } else { cout<<" "; } } cout<<endl; } for(int i=n;i>=1;i--) { for(int j=1;j<=n2+1;j++) { if(n-i+2j||n+ij) { cout<<""; } else { cout<<" "; } } cout<<endl; } }

            • -4
              @ 2022-1-12 11:44:58
              #include<stdio.h>
              #include<iostream>
              #include<math.h>
              using namespace std;
              int main()
              {
              	int n;
              	cin>>n;
              	for(int i=1;i<=n+1;i++)
              	{
              		for(int j=1;j<=n*2+1;j++)
              		{
              			if(n-i+2==j||n+i==j)
              			{
              				cout<<"*";
              			}
              			else
              			{
              				cout<<" ";
              			}
              		}
              		cout<<endl;
              	}
              	for(int i=n;i>=1;i--)
              	{
              		for(int j=1;j<=n*2+1;j++)
              		{
              			if(n-i+2==j||n+i==j)
              			{
              				cout<<"*";
              			}
              			else
              			{
              				cout<<" ";
              			}
              		}
              		cout<<endl;
              	}
              }
              
              • -6
                @ 2022-1-12 11:43:05
                #include<stdio.h>
                #include<iostream>
                #include<math.h>
                using namespace std;
                int main()
                {
                	int n;
                	cin>>n;
                	for(int i=1;i<=n+1;i++)
                	{
                		for(int j=1;j<=n*2+1;j++)
                		{
                			if(n-i+2==j||n+i==j)
                			{
                				cout<<"*";
                			}
                			else
                			{
                				cout<<" ";
                			}
                		}
                		cout<<endl;
                	}
                	for(int i=n;i>=1;i--)
                	{
                		for(int j=1;j<=n*2+1;j++)
                		{
                			if(n-i+2==j||n+i==j)
                			{
                				cout<<"*";
                			}
                			else
                			{
                				cout<<" ";
                			}
                		}
                		cout<<endl;
                	}
                }
                
                • 1

                信息

                ID
                952
                时间
                1000ms
                内存
                128MiB
                难度
                2
                标签
                递交数
                350
                已通过
                215
                上传者