Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
|
4468a14f15 | 4 years ago |
@ -0,0 +1,33 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
void diamond(int x,char c)
|
||||||
|
{
|
||||||
|
int i,j,mid;
|
||||||
|
mid = x/2 + 1;
|
||||||
|
if(x%2!=0){
|
||||||
|
for(i=1;i<=mid;i++)
|
||||||
|
{
|
||||||
|
for(j = 1;j <= mid-i;j++)
|
||||||
|
printf("\t");
|
||||||
|
for(j = 1;j <= 2*i-1;j++ )
|
||||||
|
printf("%c\t",c);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i=mid+1;i<=x;i++){
|
||||||
|
for(j = 1;j <=i-mid;j++)
|
||||||
|
printf("\t");
|
||||||
|
for(j = 1;j <= x- 2*(i-mid);j++)
|
||||||
|
printf("%c\t",c);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else printf("error!\n");
|
||||||
|
}
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int x;
|
||||||
|
char c;
|
||||||
|
scanf("%d,%c",&x,&c);
|
||||||
|
diamond(x,c);
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in new issue