1 solutions

  • 0
    @ 2025-11-5 16:30:13

    C++ :

    #include<iostream>
    #include<cstdio>
    using namespace std;
    int main()
    {
    	int n,x,sum=0;
    	cin>>n;
    	for (int i=1; i<=n; i++)
    	{
    		cin>>x;
    		sum+=x;
    	}
    	cout<<sum<<endl;
    	printf("%.1lf\n",double(sum)/n);
    	return 0;
    }
    

    Pascal :

    var a:array[1..20] of longint;
        i,h,n:longint;
        p:real;
    begin
      readln(n);
      for i:=1 to n do
      begin
        readln(a[i]);
        h:=h+a[i];
      end;
      p:=h/n;
      writeln(h);
      writeln(p:0:1);
    end.
    
    
    • 1

    Information

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