1 solutions

  • 0
    @ 2025-11-5 15:17:14

    C :

    #include<stdio.h>
    #define PI 3.1415926
    int main()
    {
    	double r,h,l,s1,v1,s2,v2;
    	scanf("%lf%lf",&r,&h);
    	l=2*PI*r;
    	s1=PI*r*r;
    	v1=s1*h;
    	s2=4*PI*r*r;
    	v2=(4.0/3)*PI*r*r*r;
    	printf("%.2lf %.2lf %.2lf %.2lf %.2lf\n",l,s1,v1,s2,v2);
    	return 0;
    }
    

    C++ :

    #include <stdio.h>
    #include <math.h>
    #define PI 3.14159265358
    int main() {
    	float r, h;
    	scanf("%f %f", &r, &h);
    	printf("%.2lf %.2lf %.2lf %.2lf %.2lf\n", PI * 2.0 * r, PI * r * r, PI * r * r * h, PI * 4.0 * r * r, PI * 4.0 / 3.0 * r * r * r);
    	return 0;
    }
    
    

    Pascal :

    var 
      r,h:double;
    
    begin
      readln(r,h);
      writeln( 2*r*pi:0:2,' ',pi*r*r:0:2,' ',
        pi*r*r*h:0:2,' ',pi*4*r*r:0:2,' ',4/3*pi*r*r*r:0:2);
    end.
    
    
    
    
    

    Java :

    import java.util.*;
    public class Main {
    	public static void main(String args[]) {
    		Scanner cin=new Scanner(System.in);
    		double r,h;
    		double a,b,c,d,e;
    		r=cin.nextDouble();
    		h=cin.nextDouble();
    		a=2*r*Math.PI;
    		b=Math.PI*r*r;
    		c=b*h;
    		d=2*a*r;
    		e=(4.0/3.0)*b*r;
    		System.out.printf("%.2f %.2f %.2f %.2f %.2f\n",a,b,c,d,e);
    	}
    }
    

    Python :

    import math
    r,h = [float(x) for x in raw_input().split()]
    print "%.2f %.2f %.2f %.2f %.2f" %(2*math.pi*r,math.pi*r*r, math.pi*r*r*h, 4*math.pi*r*r,4./3*math.pi*r*r*r)
    
    • 1

    Information

    ID
    16609
    Time
    1000ms
    Memory
    32MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By