PAT乙级-1036.跟奥巴马一起编程(15)

时间:2023-03-08 17:37:16

题解PAT乙级-1036.跟奥巴马一起编程(15)

题解:

注意“行数是列数的50%(四舍五入)”

 #include<iostream>
using namespace std;
int main()
{
int n;
char c;
cin >> n >> c;
int n1;
if (n % == )
n1 = n / - ;
else
n1 = n / - ;
for (int i = ; i < n; i++)
{
cout << c;
}
cout << endl;
for (int i = ; i < n1; i++)
{
cout << c;
for (int j = ; j < (n - ); j++)
{
cout << " ";
}
cout << c;
cout << endl;
}
for (int i = ; i < n; i++)
{
cout << c;
}
cout << endl;
return ;
}