Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # include <stdio.h>
- # include <math.h>
- # include <string.h>
- int main ( void ) {
- int n = 0;
- char ast[20];
- char symb[3] = " *";
- if ( scanf( "%d", &n ) == 1 ) {
- if ( n % 2 == 0 ) { //if n is even
- }
- else { //if n is odd
- for ( int i = 0; i <= n-1; i++ ) {
- int middle = n+i+1;
- strcat(ast, symb);
- printf( "%*s\n", middle, ast);
- }
- for ( int i = 0; i <= n-1; i++ ) {
- ast[strlen(ast)-2] = '\0';
- int middle = 2*n-i-1;
- printf( "%*s\n", middle, ast );
- }
- }
- }
- else {
- printf( "provide proper input." );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement