Home > Back-end >  C language programming, to help
C language programming, to help

Time:05-08

N line graphics, when n is 4, the graphic below,
4444444
33333
222
1
222
33333
4444444

CodePudding user response:

Reference:
 # include "stdio.h" 
Int main ()
{
Int n, I, j;
The scanf (" % d ", & amp; n);
For (I=n; I>=1; I -)
{
for(j=0; jfor(j=0; j<2 * I - 1; J++) printf (" % d ", I);
printf("\n");
}
For (I=I + 2; i<=n; I++)
{
for(j=0; jfor(j=0; j<2 * I - 1; J++) printf (" % d ", I);
printf("\n");
}

return 0;
}

//4
//4444444
//33333
//222
//1
//222
//33333
//4444444
//please press any key to continue...

CodePudding user response:

 # include & lt; Stdio. H> 
Int main () {
Int n, I, j;
The scanf (" % d ", & amp; n);
If (n<=0 | | 9 & lt; N) return 1;
For (j=0; jFor (I=0; iFor (I=0; i<2 * (n - j) - 1; I++) printf (" % d ", n - j);
printf("\n");
}
For (j=n - 2; J>=0; J -) {
For (I=0; iFor (I=0; i<2 * (n - j) - 1; I++) printf (" % d ", n - j);
printf("\n");
}

return 0;
}

CodePudding user response:

Can also be like this:
 # include & lt; Stdio. H> 
#include
Int main ()
{
int i, j;
For (I=3; i <=3; I++)
{
For (j=3; J & lt;=3; J++)
Printf (" % c ", abs (I) & gt; Abs (j)=? Abs (I) + 1 + 48:32);
printf("\n");
}
return 0;
}

CodePudding user response:

With input, you can paste type:
 # include & lt; Stdio. H> 
#include
Int main ()
{
Int I, j, n.
scanf("%d", & n);
For (I=- (n - 1); i <=(n - 1); I++) {
For (j=- (n - 1); J & lt;=(n - 1); J++)
Printf (" % c ", abs (I) & gt; Abs (j)=? Abs (I) + 1 + 48:32);
printf("\n");
}
return 0;
}
  • Related