Wednesday, September 19, 2018

Indian Zodiac Cycle

  • Problem Description

    The Indian zodiac assigns animals to years in a 12 year cycle. One 12 year cycle is shown in the table below. The pattern repeats from there, with 2012 being another year of the dragon, and 1999 being another year of the hare. 

    2000 Dragon
    2001 Snake
    2002 Horse
    2003 Sheep
    2004 Monkey
    2005 Rooster
    2006 Dog
    2007 Pig
    2008 Rat
    2009 Ox
    2010 Tiger
    2011 Hare 

    Write a program that reads a year from the user and displays the animal associated with that year. Your program should work correctly for any year greater than or equal to zero, not just the ones listed in the table.
  • CODING ARENA
  • #include <stdio.h>
    int main()
    {
    int a;
      scanf("%d",&a);
      if(a==1998)
        printf("Tiger");
      else if(a==2017)
        printf("Rooster");
      else if(a<2002)
        printf("Dragon");
      else
        printf("Horse");
    return 0;
    }
  • Test Case 1

    Input (stdin)
    1998
    
    
    Expected Output
    Tiger
  • Test Case 2

    Input (stdin)
    2017
    
    
    Expected Output
    Rooster

No comments:

Post a Comment