Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. # include <stdio.h>
  2. # include <math.h>
  3. # include <string.h>
  4.  
  5. int main ( void ) {
  6. int n = 0;
  7. char ast[20];
  8. char symb[3] = " *";
  9. if ( scanf( "%d", &n ) == 1 ) {
  10. if ( n % 2 == 0 ) { //if n is even
  11.  
  12. }
  13.  
  14. else { //if n is odd
  15. for ( int i = 0; i <= n-1; i++ ) {
  16. int middle = n+i+1;
  17. strcat(ast, symb);
  18. printf( "%*s\n", middle, ast);
  19. }
  20. for ( int i = 0; i <= n-1; i++ ) {
  21. ast[strlen(ast)-2] = '\0';
  22. int middle = 2*n-i-1;
  23. printf( "%*s\n", middle, ast );
  24. }
  25. }
  26. }
  27. else {
  28. printf( "provide proper input." );
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement