Monday, August 20, 2018

TIME MACHINE DIFFERENCE

  • Problem Description


    The Time Machine is a science fiction novella by H. G. Wells, published in 1895 and written as a frame narrative. The work is generally credited with the popularization of the concept of time travel by using a vehicle that allows an operator to travel purposely and selectively forwards or backwards in time. The term "time machine", coined by Wells, is now almost universally used to refer to such a vehicle.

    The Time Machine has been adapted into three feature films of the same name, as well as two television versions, and a large number of comic book adaptations. It has also indirectly inspired many more works of fiction in many media productions. Now kindly help our Captain of the Ship "H.G.Wells" to calculate the difference between the two time machines.

    Mandatory:

    1. Create a Structure "Time" and three data members as seconds(int), minutes(int), hours(int)

    2. The Structure Variables as "startTime, stopTime, diff"

    3.Access the data members as follows

    stopTime.seconds
    startTime.hours

    Note: The structure variables, data members and structure name are CASE Sensitive.

    Follow the same case mentioned in the mandatory
  • CODING ARENA::
  • #include <stdio.h>
    struct Time
      {
      int hours, minutes,seconds;
      }startTime,stopTime,diff;
    int main()
      {
    int a, b, c; 
      scanf("%d\t %d\t%d",&startTime. hours,&startTime.minutes,&stopTime.seconds);
      scanf("%d\t%d\t%d",&a, &b, &c);
      printf("TIME DIFFERENCE=%d:%d:%d-%d:%d:%d=%d:%d:%d",startTime.hours,startTime.minutes,stopTime.seconds,a,b,c,startTime.hours-a,startTime.minutes-b,stopTime.seconds-c);


    return 0;
    }
  • Test Case 1

    Input (stdin)
    12 34 55
    
    8 12 15
    
    
    Expected Output
    TIME DIFFERENCE=12:34:55-8:12:15=4:22:40
  • Test Case 2

    Input (stdin)
    5 34 55
    
    10 12 15
    
    
    Expected Output
    TIME DIFFERENCE=5:34:55-10:12:15=-5:22:40

No comments:

Post a Comment