1 条题解

  • 0
    @ 2026-2-10 15:41:34

    C :

    #include<stdio.h>
    int main()
    {
    	float r,h,pi=3.1415926;
    	scanf("%f%f",&r,&h);
    	printf("Area=%.3f",2*pi*r*r+2*pi*r*h);
    	
    }
    

    C++ :

    #include<stdio.h>
    int main()
    {
    	//freopen("1020A2.in","r",stdin);
    	//freopen("1020A2.out","w",stdout);
        float pi=3.1415926535,r,h,s;
        scanf("%f%f",&r,&h);
        s=2*pi*r*r+2*pi*r*h;
        printf("Area=%.3f",s);
    }
    

    Java :

    import java.util.Scanner;
    public class Main {
        public static void main(String[] args){
            Scanner input=new Scanner(System.in);
            double r=input.nextDouble();
            double h=input.nextDouble();
            double s=r*r*Math.PI*2+h*2*Math.PI*r;
            System.out.println("Area="+String.format("%.3f",s));
        }
    }
    
    

    Python :

    # coding=utf-8
    #python2
    pi=float(3.1415926)
    r,h=map(float,raw_input().split())
    s=float(pi*r*r*2+pi*r*2*h)
    print "Area=%.3f"%s
    

    C# :

    using System;
    using System.Collections.Generic;
    using System.Diagnostics.SymbolStore;
    using System.Linq;
    using System.Security.Cryptography;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace ConsoleApp2
    {
        internal class Program
        {
            static void Main()
            {
                //int[] days = { 31,28,31,30,31,30,31,31,30,31,30,31};
                string[] a1 = Console.ReadLine().Split();
                double r = Convert.ToDouble( a1[0]);
                double h = Convert.ToDouble( a1[1]);
                float pi = 3.1415926f;
                double S = pi * Math.Pow(r, 2) * 2 + 2 * pi * r * h;
    
                Console.WriteLine("Area=" +Math.Round( S,3));
    
                Console.ReadKey();
    
    
    
            }
        }
    }
    
    • 1

    信息

    ID
    15
    时间
    1000ms
    内存
    128MiB
    难度
    1
    标签
    递交数
    0
    已通过
    0
    上传者