#include <iostream>using namespace std; int main(){ char str [] = "dd yhd yw dcjkayt dvqv auyj fbajk dyusdv sddw"; int k = 9; //position int before= 0, after = 0, space = 0; for(int i = 0; i <= k; i++){ if(str[i] == ' '){ space++; } } if(str[k] != ' '){ for(int i = k + 1; str[i]; i++){ if(str[i] == ' ' || str[i] == '\0'){ after = i; break; } } for(int j = k - 1; j >= 0; j--){ if(str[j] == ' ' || j == 0){ before = j; break; } } cout<<space + 1<<" slovo "; for(int i = before; i < after; i++) cout<<str[i]; } else cout<<space<<" slovo"; return 0; }
васильевич
14.06.2020
/* C++ */ /*Массив заполняется случайными числами от -20 до 20*/ #include <iostream> #include <cstdlib> #include <ctime>
using namespace std;
int main() { setlocale(LC_ALL, "Russian"); int M[5][7], N[5][7]; int C[5], D[5]; int CountA, CountB; srand(time(NULL)); printf(" *** Массив M ***\n"); for (int i = 0; i < 5; i++) { CountA = 0; for (int j = 0; j < 7; j++) { M[i][j] = rand() % 41 - 20; if (M[i][j] < 0) CountA++; printf("%4d", M[i][j]); } C[i] = CountA; printf("\n"); } printf("\n"); printf(" *** Массив N ***\n"); for (int i = 0; i < 5; i++) { CountB = 0; for (int j = 0; j < 7; j++) { N[i][j] = rand() % 41 - 20; if (N[i][j] < 0) CountB++; printf("%4d", N[i][j]); } D[i] = CountB; printf("\n"); } printf("\n"); printf("*** Массив C ***\n"); for (int i = 0; i < 5; i++) printf("%8d\n", C[i]); printf("\n"); printf("*** Массив D ***\n"); for (int i = 0; i < 5; i++) printf("%8d\n", D[i]); printf("\n"); system("pause"); return 0; }
//================================================= //Pascal var M, N: array [1 .. 5, 1 .. 7] of integer; C, D: array [1 .. 5] of integer; i, j, CountA, CountB: integer; begin randomize; writeln(' ***** Массив M *****'); for i := 1 to 5 do begin CountA := 0; for j := 1 to 7 do begin M[i, j] := random(41) - 20; if M[i, j] < 0 then CountA := CountA + 1; write(M[i, j]:5); end; C[i] := CountA; writeln; end; writeln; writeln(' ***** Массив N *****'); for i := 1 to 5 do begin CountB := 0; for j := 1 to 7 do begin N[i, j] := random(41) - 20; if N[i, j] < 0 then CountB := CountB + 1; write(N[i, j]:5); end; D[i] := CountB; writeln; end; writeln; writeln('Массив C'); for i := 1 to 5 do writeln(C[i]:4); writeln; writeln('Массив D'); for i := 1 to 5 do writeln(D[i]:4); writeln; readln; end.
Объяснение:
25₁₀ = 1*8⁰ + 3*8¹ = 31₈
132₁₀ = 4*8⁰ + 0*8¹ + 2*8² = 204₈
421₁₀ = 5*8⁰ + 4*8¹ + 6*8² = 645₈
5473₁₀ = 1*8⁰ + 4*8¹ + 5*8² + 2*8³ + 1*8⁴ = 12541₈
1061₁₀ = 5*8⁰ + 4*8¹ + 0*8² + 2*8³ = 2045₈
335₁₀ = 15*16⁰ + 4*16¹ + 1*16² = 14F₁₆
512₁₀ = 0*16⁰ + 0*16¹ + 2*16² = 200₁₆
302₁₀ = 14*16⁰ + 2*16¹ + 1*16² = 12E₁₆
2045₁₀ = 13*16⁰ + 15*16¹ + 7*16² = 7FD₁₆
2580₁₀ = 4*16⁰ + 1*16¹ + 10*16² = A14₁₆
41₈ = 1*8⁰ + 4*8¹ = 33₁₀
33₁₀ = 3*10⁰ + 3*10¹ = 33₁₀
520₈ = 0*8⁰ + 2*8¹ + 5*8² = 336₁₀
336₁₀ = 6*10⁰ + 3*10¹ + 3*10² = 336₁₀
306₈ = 6*8⁰ + 0*8¹ + 3*8² = 198₁₀
198₁₀ = 8*10⁰ + 9*10¹ + 1*10² = 198₁₀
B5₁₆ = 5*16⁰ + B*16¹ = 181₁₀
181₁₀ = 1*10⁰ + 8*10¹ + 1*10² = 181₁₀
A28₁₆ = 8*16⁰ + 2*16¹ + A*16² = 2600₁₀
2600₁₀ = 0*10⁰ + 0*10¹ + 6*10² + 2*10³ = 2600₁₀
CD₁₆ = D*16⁰ + C*16¹ = 205₁₀
205₁₀ = 5*10⁰ + 0*10¹ + 2*10² = 205₁₀
10101111₂ = 1*2⁰ + 1*2¹ + 1*2² + 1*2³ + 0*2⁴ + 1*2⁵ + 0*2⁶ + 1*2⁷ = 175₁₀
175₁₀ = 7*8⁰ + 5*8¹ + 2*8² = 257₈
175₁₀ = 15*16⁰ + 10*16¹ = AF₁₆
11001100110₂ = 0*2⁰ + 1*2¹ + 1*2² + 0*2³ + 0*2⁴ + 1*2⁵ + 1*2⁶ + 0*2⁷ + 0*2⁸ + 1*2⁹ + 1*2¹⁰ = 1638₁₀
1638₁₀ = 6*8⁰ + 4*8¹ + 1*8² + 3*8³ = 3146₈
1638₁₀ = 6*16⁰ + 6*16¹ + 6*16² = 666₁₆
26₈ = 6*8⁰ + 2*8¹ = 22₁₀
22₁₀ = 0*2⁰ + 1*2¹ + 1*2² + 0*2³ + 1*2⁴ = 10110₂
702₈ = 2*8⁰ + 0*8¹ + 7*8² = 450₁₀
450₁₀ = 0*2⁰ + 1*2¹ + 0*2² + 0*2³ + 0*2⁴ + 0*2⁵ + 1*2⁶ + 1*2⁷ + 1*2⁸ = 111000010₂
4017₈ = 7*8⁰ + 1*8¹ + 0*8² + 4*8³ = 2063₁₀
2063₁₀ = 1*2⁰ + 1*2¹ + 1*2² + 1*2³ + 0*2⁴ + 0*2⁵ + 0*2⁶ + 0*2⁷ + 0*2⁸ + 0*2⁹ + 0*2¹⁰ + 1*2¹¹ = 100000001111₂
C3₁₆ = 3*16⁰ + C*16¹ = 195₁₀
195₁₀ = 1*2⁰ + 1*2¹ + 0*2² + 0*2³ + 0*2⁴ + 0*2⁵ + 1*2⁶ + 1*2⁷ = 11000011₂
B096₁₆ = 6*16⁰ + 9*16¹ + 0*16² + B*16³ = 45206₁₀
45206₁₀ = 0*2⁰ + 1*2¹ + 1*2² + 0*2³ + 1*2⁴ + 0*2⁵ + 0*2⁶ + 1*2⁷ + 0*2⁸ + 0*2⁹ + 0*2¹⁰ + 0*2¹¹ + 1*2¹² + 1*2¹³ + 0*2¹⁴ + 1*2¹⁵ = 1011000010010110₂
E38₁₆ = 8*16⁰ + 3*16¹ + E*16² = 3640₁₀
3640₁₀ = 0*2⁰ + 0*2¹ + 0*2² + 1*2³ + 1*2⁴ + 1*2⁵ + 0*2⁶ + 0*2⁷ + 0*2⁸ + 1*2⁹ + 1*2¹⁰ + 1*2¹¹ = 111000111000₂