Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Pascal Triangle Plotter XD

DZone's Guide to

Pascal Triangle Plotter XD

·
Free Resource

//+ Jonas Raoni Soares Silva
//@ http://jsfromhell.com

#include 
  
   
#include 
   
    

#define MAX 16

int main () {
	int unsigned vetor[MAX], grau, i = 0, j, top, left;

	clrscr();

	printf( "Dado o grau, printar o triangulo de pascal\n" );

	while( grau > MAX && printf( "Digite um numero entre 0 e %d para o grau: ", MAX ) && scanf( "%u", &grau ) );
	while( i++ < grau && !( j = 0 ) && printf( "\n" ) )
		while( j < i && ( j == 0 && ( top = left = vetor[j] = 1 ) ? 1 : j > 0 && j < i-1 && ( top = vetor[j] ) && ( vetor[j] = left + top ) && ( left = top ) ? 1 : ( vetor[j] = 1 ) ) && printf( "%-5d", vetor[j] ) && ++j );
	getch();
	return 0;
}


   
  
Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}