Solution of URI 1134::Type of Fuel
Before seeing the solution make sure that you have tried enough. Don’t copy the whole code, just find out the logic. If you feel any problem, you will inform me by comment.
#include <stdio.h>
int main() {
int code,alc=0,gas=0,die=0;
while(scanf("%d",&code)!=EOF) {
if(code == 1) {
alc++;
}
else if(code == 2) {
gas++;
}
else if(code == 3) {
die++;
}
else if(code == 4) {
printf("MUITO OBRIGADO\n");
printf("Alcool: %d\nGasolina: %d\nDiesel: %d\n",alc,gas,die);
break;
}
}
return 0;
}
No comments