1) #include <iostream> #include <conio.h> #include <string> using namespace std; int main() { string str; getline(cin, str); for (int i = 1; i < str.length(); i++) { if (i % 3 == 0) {cout << str[i] << endl;} } _getch(); return 0; } 2) #include <iostream> #include <conio.h> #include <string> using namespace std; int main() { string str; getline(cin, str); for (int i = 1; i < str.length(); i++) { if (i % 2 == 0) { if (str[i] != 'a') { str[i] = 'a'; } if (str[i] != 'b') { str[i] = 'b'; } if (str[i] != 'c') { str[i] = 'c'; } } } cout << str << endl; _getch(); return 0;}
Дмитрий74
08.05.2023
#include <iostream> #include <string> int main() { using namespace std;
//1й пункт string s1 = "Computer programming (often shortened to programming) is a process"; for (int i = 2; i < s1.size(); i = i + 3) cout << s1[i]; cout << endl;
//2й пункт string s2 = "Programming involves activities such as analysis, developing understanding"; for (int i = 1; i < s2.size(); i = i + 2) if (s2[i] != 'a' && s2[i] != 'b') s2[i] = 'a'; else s2[i] = 'c'; cout << s2 << endl;
Формула Шеннона. Всего 100 шариков.
-(10/100·㏒₂(10/100)+20/100·㏒₂(20/100)+30/100·㏒₂(30/100)+40/100·㏒₂(40/100))=-(0.1㏒₂0.1+0.2㏒₂0.2+0.3㏒₂0.3+0.4㏒₂0.4)≈1.846 бит