现场写的代码,比较乱.....
$1$.[分值:$5$] $5-11$ 编程打印空心字符菱形
模拟一下下即可
#include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<map> #include<set> #include<queue> #include<stack> #include<algorithm> #include<iostream> using namespace std; char s[5]; char m[500][500]; int r ,c ,x,n; int main() { cin>>s>>n; char now=s[0]; if(n==1) { printf("%c ",now); return 0; } r =1, c=n/2+1, x=n/2+1; while(x--) m[r][c]=now, now++, r++, c--; now=s[0], r=1, c=n/2+1, x=n/2+1; while(x--) m[r][c]=now, now++, r++, c++; now=s[0],r=n, c=n/2+1,x=n/2+1; while(x--) m[r][c]=now,now++, r--, c--; now=s[0],r=n, c=n/2+1,x=n/2+1; while(x--) m[r][c]=now,now++,r--, c++; for(int i=1;; i++) { if(m[1][i]=='