// 1118 (Mahmud_Jamil) BRUR
// Several Scores with Validation
#include <stdio.h>
int main()
{
double a,b,c,d,e,f,g,h=1,x=1,y=1,z=1;
for(h=1;;h=1,x=1,y=1,z=1)
{
scanf("%lf",&a);
if(a<0 || a>10)
{
printf("nota invalida\n");
continue;
}
while(x==1)
{
scanf("%lf",&b);
if(b<0 || b>10)
{
printf("nota invalida\n");
continue;
}
x+=2;
}
c=(a+b)/2.0;
printf("media = %.2lf\n",c);
printf("novo calculo (1-sim 2-nao)\n");
while(y==1)
{
scanf("%lf", &g);
if(g<1 || g>2)
{
printf("novo calculo (1-sim 2-nao)\n");
continue;
}
y+=2;
}
if(g==2)
break;
}
return 0;
}
#include
ReplyDeleteint main()
{
double x,y,av,n;
while(1)
{
scanf("%lf",&x);
if(x<0 || x>10)
{
printf("nota invalida\n");
continue;
}
while(1)
{
scanf("%lf",&y);
if(y<0 || y>10)
{
printf("nota invalida\n");
continue;
}
break;
}
av=(x+y)/2.0;
printf("media = %.2f\n",av);
printf("novo calculo (1-sim 2-nao)\n");
while(1)
{
scanf("%lf",&n);
if(n!=1 && n!=2)
{
printf("novo calculo (1-sim 2-nao)\n");
continue;
}
break;
}
if(n==2)
{
break;
}
}
}