В памяти компьютера (ОЗУ), если идет речь о десктопных приложениях.
В веб-программах:
PHP -- на сервере.
JS -- ОЗУ
Вероятность вытянуть красный шар 1/4
Количество информации в сообщении о том, что вытянут именно красный составляет log(4)/log(2)=2 бита
0.927 гигабайт. с такой скоростью была передача информаци по сети
#include <iostream>
using namespace std;
/*
* Сумма элементов массива
* [ 1, 2, 3] => 6
* [-5, 8, 2] => 5
*/
int arraySum(int a[], int s)
{
int ret = 0;
for (int i = 0; i < s; i++) {
ret += a[i];
}
return ret;
}
/*
* Определение, каких чисел больше в массиве.
* [-1, 2, 3] => "Положительных"
* [ 1, -2, -3] => "Отрицательных"
*/
const char* plusMinGreater(int a[], int s)
{
int plus = 0, minus = 0;
for (int i = 0; i < s; i++) {
if (a[i] > 0) plus++;
if (a[i] < 0) minus++;
}
return (plus > minus ?
"Положительных чисел больше" :
(plus < minus ?
"Отрицательных чисел больше" :
"Положителных и отрицательных поровну"));
}
/*
* Разница между максимальным и минимальным элементами.
* [5, 3, 2] => 5 - 2 = 3
*/
int maxMinDiff(int a[], int s)
{
int min = a[0], max = a[0];
for (int i = 1; i < s; i++) {
if (a[i] > max) max = a[i];
if (a[i] < min) min = a[i];
}
return max - min;
}
int main()
{
int n;
cout << "n = ";
cin >> n;
int a[n];
for (int i = 0; i < n; i++) {
cout << "Число " << i << ": ";
cin >> a[i];
}
cout << plusMinGreater(a, n) << endl
<< "Сумма: " << arraySum(a, n) << endl
<< "Разница максимального и минимального элементов: "
<< maxMinDiff(a, n) << endl;
return 0;
}
var i,l,k,n,p:integer;
s:string;
Z: set of char;
A: array[1..100] of real;
B: array[1..100] of char;
R,Buf:real;
function F(A:real; Z:char; B:real):real;
begin
case Z of
'+': result:=A+B;
'-': result:=A-B;
'*': result:=A*B;
'/': result:=A/B;
end;
end;
begin
Assign(input,'input.txt');
Assign(output,'output.txt');
Reset(input);
Rewrite(output);
Readln(S);
close(input);
L:=length(s);
k:=0;
n:=0;
Z:=['+','-','*','/'];
for i:=1 to L do
if not(S[i] in Z) then begin
inc(k);
A[k]:=StrToInt(S[i]);
end
else begin
inc(n);
B[n]:=S[i];
end;
if (S[1] in Z) then
begin
if s[1]='-' then A[1]:=A[1]*(-1);
for i:=1 to n do
b[i]:=b[i+1];
dec(n);
<span> end;
</span> i:=0;
While (i<n) do
begin
inc(i);
if ((B[i]= '*') or (B[i]='/')) then
begin
buf:=F(A[i],B[i],A[i+1]);
A[i]:=buf;
for p:=i+1 to k do
A[p]:=A[p+1];
for p:=i to n do
B[p]:=B[p+1];
dec(n);
dec(i);
end;<span>
end;</span> R:=A[1];
for i:=1 to n do
if not((B[i]= '*') or (B[i]='/')) then
R:=F(R,B[i],A[i+1]);
writeln(R);
Close(output);
end.