Код:
#include <stdio.h>
float V(float R, float r, float h)
{
if(R <= r || h <=0 || r <= 0 || R <=0)
return -1;
return (3.14 * h * (R*R + R*r + r*r)) / 3;
}
int main()
float test = V(10, 5, 5);
printf("%f\n", test);
test = V(5, 5, 1);
test = V(10, 5, 0);
test = V(5, 6, 5);
test = V(4, 3.99, 6);
printf("%f", test);
return 0;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Код:
#include <stdio.h>
float V(float R, float r, float h)
{
if(R <= r || h <=0 || r <= 0 || R <=0)
return -1;
return (3.14 * h * (R*R + R*r + r*r)) / 3;
}
int main()
{
float test = V(10, 5, 5);
printf("%f\n", test);
test = V(5, 5, 1);
printf("%f\n", test);
test = V(10, 5, 0);
printf("%f\n", test);
test = V(5, 6, 5);
printf("%f\n", test);
test = V(4, 3.99, 6);
printf("%f", test);
return 0;
}