Răspuns :
var n,t,s:integer;
begin
t:=-1;
repeat
read(n);
inc(t);
s+=n;
until n=0;
writeln('Media aritmetica: ',s/t);
end.
begin
t:=-1;
repeat
read(n);
inc(t);
s+=n;
until n=0;
writeln('Media aritmetica: ',s/t);
end.
Salut. Ti-am lasat rezolvarea si in limbajul C++. Succes!
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
int n, k = 0;;
float s = 0;
cin >> n;
do
{
s = s + n; k = k + 1;
cin >> n;
} while (n != 0);
cout << (float)s / k;
return 0;
}
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
int n, k = 0;;
float s = 0;
cin >> n;
do
{
s = s + n; k = k + 1;
cin >> n;
} while (n != 0);
cout << (float)s / k;
return 0;
}