Monday, August 20, 2018

A TASK

  • Problem Description

    A task is given to 3 persons to complete it within a particular time. If the person exceeds the time limit he will be disqualified . Only those who complete it within the given time limit is qualified. Among the qualified persons. the person who complete the task first will be rewarded.Write a C program to find the person who is rewarded.

    Input Format:

    First Input corresponds to the time limit for the task in hours . Second, third and fourth input corresponds to the number of hours taken by the first, second and third persons respectively to complete the task.

    Output format:

    Display the person who completes first.

    5
    4 4 1
    Third person wins!!

    4
    1 2 3
    First person wins!!
  • CODING ARENA
  • #include <stdio.h>
    int main()
    {
      int t,a,b,c;
      scanf("%d",&t);
      scanf("%d %d %d",&a,&b,&c);
      if(a>t && b>t && c>t)
      {
        printf("No person wins!!");
      }
      else if(a<t && a<b && a<c)
        printf("First person wins!!");
      else if(b<t && b<a && b<c)
        printf("Second person wins!!");
      else
        printf("Third person wins!!");

    return 0;
    }
  • Test Case 1

    Input (stdin)
    10
    
    5 4 7
    
    
    Expected Output
    Second person wins!!
  • Test Case 2

    Input (stdin)
    4
    
    9 6 7
    
    
    Expected Output
    No person wins!!

5 comments:

  1. There was an app to get input and displays the output as same as input correctly. Can you create an app for it. i.e.Program to get input as array and display array elements.

    ReplyDelete
  2. The hero of the story is johan....

    ReplyDelete