[Programmation] [C language] Program draw a fir tree

/* Program to display a fir tree-sapin */
#include <stdio.h>

int x,y,dim;

main()
{

printf( “Enter dimension of picture (i.e. 10): ” );
scanf( “%d”, &dim );

/* Dessiner le corp du sapin */
for ( x = 0; x <= dim; x++, printf( “\n” ) )
for ( y = 0; y <= 2*dim; y++ )
if ((x==0)|(y==0)|(y==2*dim)|(x+dim<=y)|(x+y<=dim)) printf( ” ” ); else printf(“X”);

/* Dessiner le pied du sapin */
for ( x = 0; x <= dim/4; x++, printf( “\n” ) )
for ( y = 0; y <= 2*dim; y++ )
if ((y>=dim-dim/3)&(y<=dim+dim/3)) printf( “X” ); else printf(” “);

return 0;
}

Advertisements
  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: