- #include <stdio.h>
- #include <math.h>
- double calcarea(int, int);
- double calcvolume(int, int);
- int main(void) {
- int r, h;
- double min = 0;
- for (int i=1; i<=50; i++) {
- for (int j=1; j<=50; j++) {
- double vs = calcvolume(i, j) / calcarea(i, j);
- if (vs < 1)
- if (vs > min) {
- min = vs;
- r = i; h = j;
- }
- if (vs > 1)
- if ((1 - min) > (vs - 1)) {
- min = vs;
- r = i; h = j;
- }
- }
- }
- }
- double calcarea(int r, int h){
- /* https://www.yaklass.ru/p/geometria/11-klass/nakhozhdenie-obemov-tel-10440/kak-naiti-obem-konusa-9287/re-9e3463d0-ce88-4261-8f8b-c681519ffae7 */
- double v, l;
- v = M_PI * (double)r * (double)r + M_PI * (double)r * l;
- return v;
- }
- double calcvolume(int r, int h){
- /* https://mnogoformul.ru/obem-konusa-formula-i-raschet-onlayn */
- double v;
- v = M_PI * (double)r * (double)r * (double)h / 3;
- return v;
- }