Advertisement
DraKiNs

[APP] Gerador de Datas

Jun 26th, 2011
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.61 KB | None | 0 0
  1. /*==============================================================================
  2.              _ ____        _____          __  __
  3.             (_)  _ \ ___  |_   _|__  __ _|  \/  |
  4.             | | |_) / __|   | |/ _ \/ _` | |\/| |
  5.             | |  __/\__ \   | |  __/ (_| | |  | |
  6.             |_|_|   |___/   |_|\___|\__,_|_|  |_|
  7.  
  8.                [iPs] Saber dia da Semana
  9.                 Criado por: [iPs]DraKiNs (agradecimentos a Crush)
  10.                     Versão 0.1
  11. ==============================================================================*/
  12.  
  13. #include <stdio.h>
  14.  
  15. main()
  16. {
  17.     system("title [iPs TeaM] - Que dia da semana?");
  18.     system("color 8f");
  19.  
  20.     int
  21.         day = 0,
  22.         month   = 0,
  23.         year    = 0;
  24.  
  25.     // ==== [ Dia ] ========
  26.     printf("Digite o dia: ");
  27.     scanf("%d", &day);
  28.  
  29.     // ==== [ Mês ] ========
  30.     printf("Digite o mês: ");
  31.     scanf("%d", &month);
  32.  
  33.     // ==== [ Ano ] ========
  34.     printf("Digite o ano: ");
  35.     scanf("%d", &year);
  36.  
  37.     // ==== [ Processar ] ========
  38.  
  39.     char    sStr[24]    =   ("Dia Invalido");
  40.     int  
  41.         iBissext    =   (year % 100),
  42.         iWeekDay    =   (year / 100);
  43.  
  44.     if(month < 3) month += 12,year--;
  45.     int iWeek = ((day + (month+1)*26/10 + iBissext + iBissext/4 + iWeekDay/4 - 2*iWeekDay) % 7);
  46.  
  47.     if(iWeek == 0) strcpy(sStr , ("Sábado"));
  48.     if(iWeek == 1) strcpy(sStr , ("Domingo"));
  49.     if(iWeek == 2) strcpy(sStr , ("Segunda"));
  50.     if(iWeek == 3) strcpy(sStr , ("Terça"));
  51.     if(iWeek == 4) strcpy(sStr ,  ("Quarta"));
  52.     if(iWeek == 5) strcpy(sStr ,  ("Quinta")) ;
  53.     if(iWeek == 6) strcpy(sStr ,  ("Sexta"));
  54.  
  55.     printf("O dia da semana desta data foi %s \n",sStr);
  56.     return system("pause");
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement