*
***
* * *
* * *
*********
* * *
* * *
***
*
Can Anyone Give Me The Code of This Pattern in C language? I can make the diamond and the plus sign separately but not combined. I have Got this So far. The Code of My Try is given below...
int i,j,k,n;
scanf("%d",&n);
for(i=1; i<=n; i++)
{
j=i;
while(j<=n)
{
printf(" ");
j++;
}
for(k=1; k<=2*i-1; k++)
{
if(k==1 || k==(2*i-1) || k==n)
printf("*");
else
printf(" ");
}
printf("\n");
}
for(i=n-1; i>=1; i--)
{
j=n;
while(j>=i)
{
printf(" ");
j--;
}
for(k=1; k<=2*i-1; k++)
{
if(k==1 || k==(2*i-1) || k==n)
printf("*");
else
printf(" ");
}
printf("\n");
}
Aucun commentaire:
Enregistrer un commentaire