解题思路
:
判断n是奇是偶
,奇数的话则输出n
/2+1行
,偶数的话则输出n
/2行
#include <stdio.h>
int main()
{
int n
;
char ch
;
scanf("%d %c",&n
,&ch
);
if(n
%2==0)
{
for(int i
=1;i
<=n
/2;i
++)
{
for(int j
=1;j
<=n
;j
++)
printf("%c",ch
);
printf("\n");
}
}
else
{
for(int i
=1;i
<=n
/2+1;i
++)
{
for(int j
=1;j
<=n
;j
++)
printf("%c",ch
);
printf("\n");
}
}
return 0;
}
转载请注明原文地址: https://lol.8miu.com/read-4196.html