1 条题解

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

    C :

    #include<stdio.h>
    #include<math.h>
    int main()
    {
    	int n;
    	scanf("%d",&n);
    	float a,b,c;
    	scanf("%f%f%f",&a,&b,&c);
    	printf("%.2f",(a+b+c)/n);	
    }
    

    C++ :

    #include<stdio.h>
    int main(void)
    {
        int n;
        float a;
        float b,c;
        //freopen("1023A3.in","r",stdin);
        //freopen("1023A3.out","w",stdout);
        scanf("%d%f%f%f",&n,&a,&b,&c);
        printf("%.2f\n",(a+b+c)/n);
     
        return 0;
    }
    

    Java :

    import java.util.Scanner;
    
    public class Main {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            float sum = 0;
            for (int i = 0;i<3;i++){
                float a = sc.nextFloat();
                sum+=a;
            }
            System.out.printf("%.2f",sum/n);
        }
    }
    

    Python :

    # coding=utf-8
    #python2
    a = int(input())
    b,c,d = map(float,raw_input().split())
    x = (b+c+d)/a
    print('%.2f'%x)
    
    

    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};
                int n = Convert.ToInt32 (Console.ReadLine());
                string[] a1 = Console.ReadLine().Split();
                double r = Convert.ToDouble(a1[0]);
                double b = Convert.ToDouble(a1[1]);
                double c = Convert.ToDouble(a1[2]);
                float pi = 3.1415926f;
                string S = ((r + b+c) / n).ToString("0.00");
    
                Console.WriteLine(S);
    
                Console.ReadKey();
    
            }
        }
    }
    
    • 1

    信息

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