2 条题解

  • 1
    @ 2024-2-6 9:31:27
    #include <iostream>
    using namespace std;
    int main()
    {
        int n;
        cin >> n;
        for (int i = 1; i <= n; i++)
        {
            for (int j = 1; j <= n - i; j++)
            {
                cout << "*";
            }
            for (int j = 1; j <= i * 2 - 1; j++)
            {
                cout << "@";
            }
            for (int j = 1; j <= n - i; j++)
            {
                cout << "*";
            }
            cout << endl;
        }
        return 0;
    }
    
    • 0
      @ 2023-3-27 22:05:06

      每层分别按顺序输出*,@和*

      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
          int n;
          cin>>n;
          for (int i=n-1;i>=0;i--)
          {
              for (int j=1;j<=i;j++)
                  cout<<"*";
              for (int j=1;j<=(n-i)*2-1;j++)
                  cout<<"@";
              for (int j=1;j<=i;j++)
                  cout<<"*";
              cout<<'\n';
          }
          return 0;
      }
      
      • 1

      信息

      ID
      491
      时间
      1000ms
      内存
      128MiB
      难度
      1
      标签
      递交数
      60
      已通过
      54
      上传者