Срочно!!!!!!! Задачи по информатике . 1)Дана строка. Показать третий, шестой, девятый и так далее символы. 2)Дана строка. Заменить каждый четный символ или на 'a', если символ не равен 'a' или 'b', или на 'c' в противном случае
Answers & Comments
Nove1990
#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;
Answers & Comments
#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;
return 0;
}