#include
int diamond(int n,char c)
{
int i,j,v,t;
t=n/2;
for(i=1;i<=t;i++){
for(j=1;j<=t+1-i;j++)
printf(" ");
for(v=1;v<=2*i-1;v++)
printf("%c",c);
printf("\n");
}
for(i=t+1;i>=1;i--){
for(j=0;j<=t-i;j++)
printf(" ");
for(v=1;v<=2*i-1;v++)
printf("%c",c);
printf("\n");
}
return 0;
}
int is_even(int n)
{
if (n%2==0)
return 1;
else
return 0;
}
int main(void)
{
int num;
char ch;
printf("Please input a num and a char:\n");
scanf("%d %c",&num,&ch);
if(is_even(num)||num<=0){
printf("The num is error!Please input again\n");
scanf("%d %c",&num,&ch);
}
diamond(num,ch);
return 0;
}
阅读(445) | 评论(0) | 转发(0) |