Code For Alls..!

get the code!!

Saturday, 16 September 2017

Head Count - Birds and Animals

                                                Head Count - Birds and Animals
Head Count - Birds and Animals

In a zoo there are some birds and animals. All birds have two legs and all animals have four legs.
GIven the head count and leg count of both birds and animals taken together, the program must print the head count of birds and animals separated by a space as output.
Input Format:
First line will contain the integer value H representing the head count of both birds and animals taken together.
Second line will contain the integer value L representing the leg count of both birds and animals taken together.
Output Format:
First line will contain the integer values of the head count of birds and animals separated by a space.
Constraints:
0 < H < 1000
1 < L < 2000
Sample Input/Output:
Example 1:
Input:
27
84
Output:
12 15
Explanation:
There are 12 birds and 15 animals.
Example 2:
Input:
114
256
Output:
100 14
Explanation:
There are 100 birds and 14 animals.
C program:
#include<stdio.h>
#include <stdlib.h>

int main()
{
int h,l;
scanf("%d%d",&h,&l);
int a=l/2-h;
printf("%d %d",h-a,a);
}

5 comments:

  1. for writing the program in python:
    head=int(input())
    legs=int(input())
    animals=int(legs/2)-head
    birds=head-animals
    print(birds,animals)

    ReplyDelete
    Replies
    1. instead of int(legs/2) ...use legs//2

      Delete
  2. Casinos in Las Vegas - DRMCD
    A full list of 공주 출장안마 all casinos in Las 군산 출장안마 Vegas: Casinos in 거제 출장마사지 Las Vegas, Las Vegas, Nevada, Nevada. 원주 출장샵 Use our list to 안동 출장샵 filter by casino type.

    ReplyDelete