7 条题解

  • 3
    @ 2023-7-29 14:49:45
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int a,b,c;char n;
        cin>>a>>b>>n>>c;
        if (c)
        {
            for (int i=1;i<=a;i++)
            {
                for (int j=1;j<=b;j++)
                    cout<<n;
                cout<<endl;
            }    
        }
        else
        {
            for (int i=1;i<=b;i++)
            {
                cout<<n;
            }
            cout<<endl;
            for (int i=1;i<=a-2;i++)
            {
                cout<<n;
                for (int j=1;j<=b-2;j++)
                {
                    cout<<' ';
                }
                cout<<n<<endl;
            }
            for (int i=1;i<=b;i++)
            {
                cout<<n;
            }
            cout<<endl;
        }
        return 0;
    } 
    

    为什么我写得那么长啊···

    • 2
      @ 2023-7-29 22:34:54

      `

      #include<bits/stdc++.h>
      using namespace std;
      void One(int b,int a,char s){
          for(int i=1;i<=a;i++){
              for(int j=1;j<=b;j++){
                  cout<<s;
              }
              cout<<endl;
          }
      }
      void Zero(int b,int a,char s){
          for(int i=1;i<=a;i++){
              for(int j=1;j<=b;j++){
                  if(i==1 || i==a || j==1 || j==b) cout<<s;
                  else cout<<" ";
              }
              cout<<endl;
          }
      }
      int main(){
          int a,b,n;
          char s;
          cin>>a>>b>>s>>n;
          if(n==0) Zero(b,a,s);
          else if(n==1) One(b,a,s);
          return 0;
      }
      
      • 2
        @ 2023-7-24 23:07:51
        #include <iostream>
        int main(){
            int h,w,q;char a;std::cin>>h>>w>>a>>q;
            for(int i=1;i<=h;i++){
                for(int j=1;j<=w;j++){
                    if(i==1||i==h||j==1||j==w||q==1) std::cout<<a;
                    else std::cout<<" ";}
                std::cout<<"\n";}
            return 0;}
        
        • 1
          @ 2024-6-16 11:13:34
          #include<bits/stdc++.h>
          using namespace std;
          int main(){
              int a,b,d;
              char c;
              cin>>a>>b>>c>>d;
              if (d==1)
              {
                  for (int i=1;i<=a;i++)
                  {
                      for (int j=1;j<=b;j++)
                      {
                          cout<<c;
                      }
                      cout<<endl;
                  }
              }
              else
              {
                  for (int i=1;i<=a;i++)
                  {
                      for (int j=1;j<=b;j++)
                      {
                          if (i==1 || j==1 )
                          {
                              cout<<c;
                          }
                          else if(i==a || j==b)
                          {
                              cout<<c;
                          }
                          else
                          {
                              cout<<" ";
                          }
                      }
                      cout<<endl;
                  }
              }
              return 0;
          }
          呵呵,就说有一亿点长好吧🤭
          ```点个赞呗!
          
          • 1
            @ 2023-6-24 21:50:36
            #include<iostream>
            #include<iomanip>
            using namespace std;
            int main(){
            	int n,m;
            	char a;
            	bool b;
            	cin>>n>>m>>a>>b;
            	for(int i =1;i<=n;i++){
            		for(int j = 1;j<=m;j++){
            			if(i == 1||i == n){
            				cout<<a;
            			}
            			else{
            				if(b){
            					cout<<a;
            				}
            				else if(j==1||j==m){
            					cout<<a;
            				}
            				else{
            					cout<<" ";
            				}				
            			}
            		}
            		cout<<"\n";
            	}
            }
            
            • 0
              @ 2024-6-1 21:02:30
              #include <bits/stdc++.h>
              using namespace std;
              int main()
              {
                  int a,b;
                  char c;
                  int d;
                  cin >> a >> b >> c >> d;
                  if(d == 1)
                  {
                      for(int i = 1;i<=a;i++)
                      {
                          for(int j = 1;j<=b;j++)
                          {   cout << c;
                              
                          }
                          cout << endl;
                      }
                      
                  }
                  else if(d == 0)
                  {
                      for(int i = 1;i<=a;i++)
                      {
                          for (int j = 1;j<=b;j++)
                          {
                              if(i == 1||i ==a||j ==1||j==b)
                                  cout << c;
                              else
                                  cout << " ";
                          }
                          cout << endl;
                      }
                  }
                  return 0;
              }
              
              • -1
                @ 2024-1-31 17:03:41
                #include<bits/stdc++.h>
                using namespace std;
                int main()
                {
                    int a,b,c;char n;
                    cin>>a>>b>>n>>c;
                    if (c)
                    {
                        for (int i=1;i<=a;i++)
                        {
                            for (int j=1;j<=b;j++)
                                cout<<n;
                            cout<<endl;
                        }    
                    }
                    else
                    {
                        for (int i=1;i<=b;i++)
                        {
                            cout<<n;
                        }
                        cout<<endl;
                        for (int i=1;i<=a-2;i++)
                        {
                            cout<<n;
                            for (int j=1;j<=b-2;j++)
                            {
                                cout<<' ';
                            }
                            cout<<n<<endl;
                        }
                        for (int i=1;i<=b;i++)
                        {
                            cout<<n;
                        }
                        cout<<endl;
                    }
                    return 0;
                }
                

                更适合中国宝宝体制的代码

                
                
                • 1

                信息

                ID
                189
                时间
                1000ms
                内存
                128MiB
                难度
                2
                标签
                递交数
                131
                已通过
                81
                上传者