diamond图形
时间:2010-06-05 来源:goldwool2002
#include <stdio.h>
#include <stdlib.h>
void diamond(int , char);
int main(void)
{
int n ,a;
n = 5;
a = '+';
diamond(n,a);
return 0;
}
void diamond(int x, char y)
{
if(!x%2)
printf("Please input even ");
int i,j;
for (i=1; i <=x; i++){
for (j=1; j<=x-abs(i-x/2-1); j++){
if (j >= abs(i-x/2-1)+1)
printf("%c\t",y);
else
printf(" \t");
}
printf("\n");
}
}
#include <stdlib.h>
void diamond(int , char);
int main(void)
{
int n ,a;
n = 5;
a = '+';
diamond(n,a);
return 0;
}
void diamond(int x, char y)
{
if(!x%2)
printf("Please input even ");
int i,j;
for (i=1; i <=x; i++){
for (j=1; j<=x-abs(i-x/2-1); j++){
if (j >= abs(i-x/2-1)+1)
printf("%c\t",y);
else
printf(" \t");
}
printf("\n");
}
}
相关阅读 更多 +