nikolas_serafini

Lista 2 - Exercício 31

May 26th, 2013
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.20 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. void agecal(day,month,year,currd,currm,curry)
  5. {
  6.     int totald,lifey,lifem,lifed;
  7.  
  8.     totald = (curry*365 + currm*30 + currd) - (year*365 + month*30 + day);
  9.     lifey = totald/365;
  10.     lifem = (totald%365)/30;
  11.     lifed = totald - (lifey*365 + lifem*30);
  12.  
  13.     printf("Voce possui %d anos, %d meses e %d dias de vida.\n",lifey,lifem,lifed);
  14.     return;
  15. }
  16.  
  17. int main()
  18. {
  19.        
  20.     int day,month,year,currd,currm,curry;
  21.  
  22.     printf("Entre com a sua data de nascimento : (formato dd/mm/yyyy)\n");
  23.     scanf("%d %d %d",&day,&month,&year);
  24.     printf("Entre com a data de hoje : (formato dd/mm/yyyy\n");
  25.     scanf("%d %d %d",&currd,&currm,&curry);    
  26.  
  27.     agecal(day,month,year,currd,currm,curry);
  28.  
  29.     if ((month<3)&&(month>=1))
  30.     {
  31.         printf("Voce nasceu no primeiro trimestre!\n");
  32.         if ((month==1)&&(day<=20)) printf("Signo : Capricornio!\n");
  33.         else if ((month<=2)&&(day<=19)) printf("Signo : Aquario!\n");
  34.         else printf("Signo : Peixes!\n");
  35.     }
  36.     else if ((month<6)&&(month>=1))
  37.     {
  38.         printf("Voce nasceu no segundo trimestre!\n");
  39.         if ((month==3)&&(day<=20)) printf("Signo : Peixes!\n");
  40.         else if ((month<=4)&&(day<=20)) printf("Signo : Aries!\n");
  41.         else if ((month<=5)&&(day<=21)) printf("Signo : Touro!\n");
  42.         else printf("Signo : Gemeos!\n");
  43.     }
  44.     else if ((month<9)&&(month>=1))
  45.     {
  46.         printf("Voce nasceu no terceiro trimestre!\n");
  47.         if ((month==6)&&(day<=21)) printf("Signo : Gemeos!\n");
  48.         else if ((month<=7)&&(day<=23)) printf("Signo : Cancer!\n");
  49.         else if ((month<=8)&&(day<=23)) printf("Signo : Leao!\n");
  50.         else printf("Signo : Virgem!\n");
  51.     }
  52.     else if ((month<=12)&&(month>=1))
  53.     {
  54.         printf("Voce nasceu no quarto trimestre!\n");
  55.         if ((month==9)&&(day<=23)) printf("Signo : Virgem!\n");
  56.         else if ((month<=10)&&(day<=23)) printf("Signo : Libra!\n");
  57.         else if ((month<=11)&&(day<=22)) printf("Signo : Escorpiao!\n");
  58.         else if ((month<=12)&&(day<=21)) printf("Signo : Sagitario!\n");
  59.         else printf("Signo : Capricornio!\n");
  60.     }
  61.     else printf("DATA INVALIDA!\n");
  62.  
  63.     return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment