Advertisement
Riposati

Untitled

Dec 5th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.80 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     int valor,i=1,j=1,t=1;
  7.     int contaEValidaEspacos=0;
  8.     int contaEValidaEspacosPeDaArvore;
  9.     int z=0;
  10.  
  11.     while(scanf("%d",&valor)!=EOF){
  12.  
  13.             for(i=1;i<=valor;i++){
  14.                 while(t <= valor){
  15.                     contaEValidaEspacos++;
  16.                     t+=2;
  17.                 }
  18.             }
  19.  
  20.             contaEValidaEspacosPeDaArvore = contaEValidaEspacos;
  21.             z=0;
  22.             t=i=j=1;
  23.  
  24.             for(i=1;i<=valor;i++){
  25.                 while(t <= valor){
  26.                     for(z=0;z<contaEValidaEspacos;z++){
  27.                         if(z<contaEValidaEspacos-1)
  28.                         printf(" ");
  29.                     }
  30.  
  31.                     for(j=1;j<=t;j++){
  32.                         if(j<=t)
  33.                         printf("*");
  34.                     }
  35.  
  36.                     if(t <= valor){
  37.                         printf("\n");
  38.                     }
  39.                     t+=2;
  40.                     contaEValidaEspacos--;
  41.                 }
  42.             }
  43.  
  44.  
  45.             t=i=j=1;
  46.             while(t <= 3){
  47.                     for(z=0;z<contaEValidaEspacosPeDaArvore;z++){
  48.                         if(z<contaEValidaEspacosPeDaArvore-1)
  49.                             printf(" ");
  50.                     }
  51.                      
  52.                     for(j=1;j<=t;j++){
  53.                         if(j<=t)
  54.                         printf("*");
  55.                     }
  56.                      
  57.                     if(t < 3){
  58.                         printf("\n");
  59.                     }
  60.                     t+=2;
  61.                     contaEValidaEspacosPeDaArvore--;
  62.                 }
  63.  
  64.             contaEValidaEspacos=0;
  65.             valor,i=1,j=1,t=1;
  66.             printf("\n\n");
  67.  
  68.     }
  69.     return 0;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement