1 条题解

  • 0
    @ 2025-4-12 21:54:23

    C++ :

    #include<iostream>
    #include<cstdio>
    using namespace std;
    int main()
    {
    	int x,t=0;
    	double ans=0;
    	while (cin>>x && x!=-1)
    		if (x%2==0)
    		{
    			ans+=x;
    			t++;
    		}
    	printf("%.2lf\n",ans/t);
    	return 0;
    }
    

    Pascal :

    program p2690(input,output);
    var
      n,s,t:longint;
      a:real;
    begin
      n:=0;
      s:=0;
      t:=0;
      while n<>-1 do
        begin
          read(n);
          if (n mod 2=0) then
            begin
              s:=s+n;
              t:=t+1;
            end;
        end;
      a:=s/t;
      writeln(a:0:2);
    end.
    
    • 1

    信息

    ID
    2377
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者