URI Online Judge | 1134
Tipo de Combustível
Adaptado por Neilor Tonin, URI
Brasil
Timelimit: 1
BrasilUm Posto de combustíveis deseja determinar qual de seus produtos tem a preferência de seus clientes. Escreva um algoritmo para ler o tipo de combustível abastecido (codificado da seguinte forma: 1.Álcool 2.Gasolina 3.Diesel 4.Fim). Caso o usuário informe um código inválido (fora da faixa de 1 a 4) deve ser solicitado um novo código (até que seja válido). O programa será encerrado quando o código informado for o número 4.
Entrada
A entrada contém apenas valores inteiros e positivos.
Saída
Deve ser escrito a mensagem: "MUITO OBRIGADO" e a quantidade de clientes que abasteceram cada tipo de combustível, conforme exemplo.
URI Online Judge | 1134
Type of Fuel
Adapted by Neilor Tonin, URI
Brazil
Timelimit: 1
BrazilA gas station wants to determine which of their products is the preference of their customers. Write a program to read the type of fuel supplied (coded as follows: 1. Alcohol 2. Gasoline 3. Diesel 4. End). If you enter an invalid code (outside the range of 1 to 4) a new code must be requested. The program will end when the inserted code is the number 4.
Input
The input contains only integer and positive values.
Output
It should be written the message: "MUITO OBRIGADO" and the amount of customers who fueled each fuel type, as an example..
#include <stdio.h>
int main() {
int X = 0;
int fuel=0;
int alcool=0;
int gasolina=0;
int diesel=0;
while (X != 4) {
scanf("%d", &X);
if (X == 1) {
alcool+=1;
}else if (X == 2) {
gasolina += 1;
}else if (X == 3) {
diesel += 1;
}
}
printf("MUITO OBRIGADO\n");
printf("Alcool: %d\n", alcool);
printf("Gasolina: %d\n", gasolina);
printf("Diesel: %d\n", diesel);
return 0;
}
Nenhum comentário:
Postar um comentário