URI / BEE CROWD 1117 - Score Validation - Solution in C,C++,Python | URI - BEECROWD - BEE 1117 Solution in C,C++,Python
beecrowd | 1117
Score Validation
Adapted by Neilor Tonin, URI Brazil
Timelimit: 1URI / BEE CROWD 1117 - Score Validation - Solution in C,C++,Python | URI - BEECROWD - BEE 1117 Solution in C,C++,Python:
Write a program that reads two scores of a student. Calculate and print the average of these scores. Your program must accept just valid scores [0..10]. Each score must be validated separately.
Input
The input file contains many floating-point numbers, positive or negative. The program execution will be finished after the input of two valid scores.
Output
When an invalid score is read, you should print the message "nota invalida".
After the input of two valid scores, the message "media = " must be printed followed by the average of the student. The average must be printed with 2 numbers after the decimal point.
Input Sample | Output Sample |
-3.5 | nota invalida |
Demonstration:
URI / BEE 1117 Solution in C :
URI / BEECROWD Online Judge 1117 Solve in C : |
#include <stdio.h>
int main()
{
double a,b,c=0,d=0;
while(1)
{
if(d==2)
break;
scanf("%lf", &a);
if(a>=0 && a<=10)
{
d++;
c+=a;
}
else
printf("nota invalida\n");
}
b=c/2.00;
printf("media = %.2lf\n", b);
return 0;
}
0 Response to URI / BEE CROWD 1117 - Score Validation - Solution in C,C++,Python | URI - BEECROWD - BEE 1117 Solution in C,C++,Python
Post a Comment