Last active
March 2, 2018 12:17
-
-
Save m0hmad/375bb5bae41b738ecd96c0056d431f57 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int wtree( int storey ) | |
{ | |
return 1 + ( (4 + 2 * ( storey - 1 )) / 2 ) * storey ; | |
} | |
int main( int argc, char **argv ) | |
{ | |
int st; | |
if ( argc < 2 ) { | |
printf( "Error Input: no argument\n" ); | |
return 1; | |
} | |
if ( !( st = atoi( argv[1] ) ) ) { | |
printf( "Error: Not entered a number\n" ); | |
return 2; | |
} | |
printf( "%d\n", wtree( st ) ); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment