Skip to content

Instantly share code, notes, and snippets.

@m0hmad
Last active March 2, 2018 12:17
Show Gist options
  • Save m0hmad/375bb5bae41b738ecd96c0056d431f57 to your computer and use it in GitHub Desktop.
Save m0hmad/375bb5bae41b738ecd96c0056d431f57 to your computer and use it in GitHub Desktop.
#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