Wednesday, 4 April 2018

uva 10070 Leap Year or Not Leap Year solution

  1. #include<stdio.h>
  2. #include<string.h>
  3. int main(void)
  4. {
  5.     char y[100001];
  6.     int m4,m100,m400,m15,m55,i,l,count=0;
  7.     while (scanf("%s",&y)==1)
  8.     {
  9.         m4=0;
  10.         m100=0;
  11.         m15=0;
  12.         m55=0;
  13.         m400=0;
  14.         if (count>0)
  15.             printf("\n");
  16.         count++;
  17.         l=strlen(y);
  18.         for (i=0;i<l;i++)
  19.         {
  20.             m4=(m4*10+y[i]-'0')%4;
  21.             m55=(m55*10+y[i]-'0')%55;
  22.             m15=(m15*10+y[i]-'0')%15;
  23.             m100=(m100*10+y[i]-'0')%100;
  24.             m400=(m400*10+y[i]-'0')%400;
  25.         }
  26.         if ((!m4 && m100) || !m400)
  27.         {
  28.             printf("This is leap year.\n");
  29.             if (!m15)
  30.                 printf("This is huluculu festival year.\n");
  31.             if (!m55)
  32.                 printf("This is bulukulu festival year.\n");
  33.         }
  34.         else
  35.         {
  36.             if (!m15)
  37.                 printf("This is huluculu festival year.\n");
  38.             else
  39.                 printf("This is an ordinary year.\n");
  40.         }
  41.     }

  42.     return 0;
  43. }

No comments:

Post a Comment

variable declaration of c program

#include <stdbool.h> #include<bits/stdc++.h> #include <stdio.h> #include <string.h> #include <std...