Комменты в коде По пунктам:
C++Выделить код
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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 #include <iostream> #include <stdio.h> #include <string> #include <fstream> #include <Windows.h> int main() { std::fstream myfile; std::string parse_string,word; std::string::size_type beg_idx = 0, end_idx = 0; const std::string delim_string (" "); int howManyStrings = 0; bool onlyTwo = true; myfile.open("file.txt",std::ifstream::in); while(!myfile.eof()) { beg_idx = 0, end_idx = 0; getline(myfile,parse_string); //Ваш 2й пункт. howManyStrings++; //Ваш 1й пункт. 11 11 22 55 33 66 88 44 99 111 222 5555 8888 77 99
Var a:array [1..10] of integer;
i,k1,k2:integer;
begin
for i:= 1 to 10 do
a[i]:= Random(20,100);
writeln(a);
for i:=1 to 10 do
if a[i] mod 2 = 0 then k1:=k1+1
else k2:=k2+1;
writeln('Чётных элементов: ',k1);
writeln('Нечётных элементов: ',k2)
end.
//PascalABC.NET v3.3 1633
const n = 15;
var arr: array [1..n] of integer;
begin
for var i:=1 to n do
arr[i]:=random(-5,5);
write('Исходный массив: ');
arr.PrintLn(', ');
var count:=0;
for var i:=1 to n do
if arr[i] > 0 then
count += 1;
writeln('Количество положительных элементов: '+count);
end.
<span>c. 0+0=0, 1+0=1, 0+1=1, 1+1=0
5.</span>100110101002 на 11002≈9099263
9099263₁₀=1000 1010 1101 0111 1111 1111₂
<span>
</span>