-
Lenguaje
Pascal
-
Descripción
Un grupo de datos tiene N valores para x, lea estos valores y calcule, donde:
∑x = suma de los valores de x
∑x² = suma de los cuadrados de lo valores de x
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
program YSx2Sx2NN1;
uses crt;
var i, n : integer;
var sumatoria_2, sumatoria_x, x, y : real;
begin
sumatoria_2 := 0;
sumatoria_x := 0;
y := 0;
write ('Ingresa el valor de n: ');
readln (n);
for i:=1 to n do
begin
writeln ('PROCESO ', i);
write ('Ingresa el valor de x: ');
readln (x);
sumatoria_x := sumatoria_x+x;
sumatoria_2 := sumatoria_2+x*x;
writeln;
end;
y := sqrt((sumatoria_2-sumatoria_x*sumatoria_x/n)/(n-1));
writeln ('Valor de sumatoria 2: ', sumatoria_2:0:6);
writeln ('Valor de sumatoria x: ', sumatoria_x:0:6);
writeln ('Valor de y: ', y:0:6);
write ('Presiona una tecla para terminar . . . ');
readkey;
end.
uses crt;
var i, n : integer;
var sumatoria_2, sumatoria_x, x, y : real;
begin
sumatoria_2 := 0;
sumatoria_x := 0;
y := 0;
write ('Ingresa el valor de n: ');
readln (n);
for i:=1 to n do
begin
writeln ('PROCESO ', i);
write ('Ingresa el valor de x: ');
readln (x);
sumatoria_x := sumatoria_x+x;
sumatoria_2 := sumatoria_2+x*x;
writeln;
end;
y := sqrt((sumatoria_2-sumatoria_x*sumatoria_x/n)/(n-1));
writeln ('Valor de sumatoria 2: ', sumatoria_2:0:6);
writeln ('Valor de sumatoria x: ', sumatoria_x:0:6);
writeln ('Valor de y: ', y:0:6);
write ('Presiona una tecla para terminar . . . ');
readkey;
end.