I am trying to solve the above pattern in c in order to create a square into the center of a bigger square.
By far i can only make the big square. p.e. :input=6
******
* *
* ** *
* ** *
* *
******
int main(int argc, char *argv[]) {
int i,j,n;
scanf("%d",&n);
//FIRST LINE
for(i = 0; i < n; i++)
{
printf("*");
}
printf("\n");
for(i = 1; i <n-1; i++)
{
printf("*");
for(j = 1; j <n-1; j++)
{
printf(" ");
}
printf("*");
printf("\n");
}
//lAST LINE
for(i = 0; i < n; i++)
{
printf("*");
}
printf("\n");
return 0;
}
Aucun commentaire:
Enregistrer un commentaire