Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
31582 | 惠子铭 | 画矩形 | C++ | Accepted | 1 MS | 252 KB | 904 | 2023-11-19 18:32:41 |
#include<iostream> #include<cstdio> #include<cmath> using namespace std; int main() { int a,b;//定义行和列 char c;//定义画矩形的时候要用的字符 bool x;//判断实心空心 int i,j; cin>>a>>b; cin>>c; cin>>x; if(x)//实心 { for(i=1;i<=a;i++)//循环高或宽 { for(j=1;j<=b;j++) cout<<c;//循环宽或高 cout<<endl;//换行忘了全都凉 } } else//空心 { for(i=1;i<=a;i++) { for(j=1;j<=b;j++) { if((i==1)||(i==a)||(j==1)||(j==b))//输出列或行首尾的字符 cout<<c; else cout<<" ";//输出行或列中间空着的部分 } cout<<endl;//换行不能忘 } } cout<<endl; return 0; }