题解 | 牛牛的字符菱形
牛牛的字符菱形
https://www.nowcoder.com/practice/11a5040fa894430f9d25fda1be37ddc8
#include <iostream>
using namespace std;
int main() {
int n=5;
char ch;
cin>>ch;
for(int i=1;i<=n;i++)
{
switch(i){
case 1:
case 5:
cout<<" "<<ch<<endl;
break;
case 2:
case 4:
cout<<" "<<ch<<ch<<ch<<endl;
break;
case 3:
cout<<""<<ch<<ch<<ch<<ch<<ch<<endl;
break;
default:;
}
}
}
// 64 位输出请用 printf("%lld")
查看1道真题和解析