Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.47 KB | None | 0 0
  1. #include <stdio.h>
  2. int n, i;
  3. int main ()
  4. {
  5.     FILE *fp = fopen("a.txt", "r");
  6.     fscanf(fp, "%i", &n);
  7.     int dw = 4;
  8.     if(n < 1 || n > 366)
  9.     {
  10.         printf("error");
  11.         return 0;
  12.     }
  13.     printf("It is ");
  14.     for(i = 1; i <= n; i++)
  15.     {
  16.         dw++;
  17.         dw %= 7;
  18.     }
  19.     if(dw == 0)
  20.     {
  21.         printf("Sunday, ");
  22.     }
  23.     if(dw == 1)
  24.     {
  25.         printf("Monday, ");
  26.     }
  27.  
  28.     if(dw == 2)
  29.     {
  30.         printf("Tuesday, ");
  31.     }
  32.  
  33.     if(dw == 3)
  34.     {
  35.         printf("Wednesday, ");
  36.     }
  37.  
  38.     if(dw == 4)
  39.     {
  40.         printf("Thursday, ");
  41.     }
  42.  
  43.     if(dw == 5)
  44.     {
  45.         printf("Friday, ");
  46.     }
  47.  
  48.     if(dw == 6)
  49.     {
  50.         printf("Saturday, ");
  51.     }
  52.     if(n <= 31)
  53.     {
  54.         printf("January %i ", n);
  55.         return 0;
  56.     }
  57.     n -= 31;
  58.     if(n <= 29)
  59.     {
  60.         printf("February %i ", n);
  61.         return 0;
  62.     }
  63.     n -= 29;
  64.  
  65.     if(n <= 31)
  66.     {
  67.         printf("March %i ", n);
  68.         return 0;
  69.     }
  70.     n -= 31;
  71.  
  72.     if(n <= 30)
  73.     {
  74.         printf("April %i ", n);
  75.         return 0;
  76.     }
  77.     n -= 30;
  78.  
  79.     if(n <= 31)
  80.     {
  81.         printf("May %i ", n);
  82.         return 0;
  83.     }
  84.     n -= 31;
  85.  
  86.     if(n <= 30)
  87.     {
  88.         printf("June %i ", n);
  89.         return 0;
  90.     }
  91.     n -= 30;
  92.  
  93.     if(n <= 31)
  94.     {
  95.         printf("July %i ", n);
  96.         return 0;
  97.     }
  98.     n -= 31;
  99.  
  100.     if(n <= 31)
  101.     {
  102.         printf("August %i ", n);
  103.         return 0;
  104.     }
  105.     n -= 31;
  106.  
  107.     if(n <= 30)
  108.     {
  109.         printf("September %i ", n);
  110.         return 0;
  111.     }
  112.     n -= 30;
  113.  
  114.     if(n <= 31)
  115.     {
  116.         printf("October %i ", n);
  117.         return 0;
  118.     }
  119.     n -= 31;
  120.  
  121.     if(n <= 30)
  122.     {
  123.         printf("November %i ", n);
  124.         return 0;
  125.     }
  126.     n -= 30;
  127.  
  128.     if(n <= 31)
  129.     {
  130.         printf("December %i ", n);
  131.         return 0;
  132.     }
  133.     n -= 31;
  134.  
  135. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement