1 solutions

  • 0
    @ 2025-11-5 17:19:24

    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

    Information

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