Friday, October 26, 2018

Uri 1134 solution in C | Type of Fuel

/*Before seeing the code solution make sure that you have tried enough. Don’t copy- paste the whole code. Find out the logic. If you face any trouble, just inform me in comment.*/

#include<stdio.h>
main()
{
    int a,x=0,y=0,z=0;
    while(1)
    {
        scanf("%d",&a);
        if(a==4)
            break;
        else
        {
            if(a==1)
            {
                x++;
            }
            else if(a==2)
            {
                y++;
            }
           else if(a==3)
            {
                z++;
            }
            else
                continue;
        }
    }
    printf("MUITO OBRIGADO\nAlcool: %d\nGasolina: %d\nDiesel: %d\n",x,y,z);
    return 0;
}

 //Happy_Coding

No comments:

Post a Comment