int main() { std::string str; getline(std::cin,str);
const int n = 5; std::string c[n] = { "=", "==", "!=", "a +=", "a -=" }; std::string psl[n] = { ": =", "=", "#", "a = a +", "a = a -" };
for (unsigned int i = n-1; i > 0; i--){ int p = str.find(c[i]); while (p > 0) { str.replace(p, c[i].size(), psl[i]); p = str.find(c[i]); } } std::cout << str; return 0; }
#include <string>
int main()
{
std::string str;
getline(std::cin,str);
const int n = 5;
std::string c[n] = { "=", "==", "!=", "a +=", "a -=" };
std::string psl[n] = { ": =", "=", "#", "a = a +", "a = a -" };
for (unsigned int i = n-1; i > 0; i--){
int p = str.find(c[i]);
while (p > 0)
{
str.replace(p, c[i].size(), psl[i]);
p = str.find(c[i]);
}
}
std::cout << str;
return 0;
}
{
if (tnum < tden)
{
temp = tnum;
tnum = tden;
tden = temp;
}
tnum = tnum - tden;
}
gcd = tden; //вычисляем наибольший общий делитель
numerator = numerator / gcd; //делим числитель и знаменатель на
НОД, получаем сокращенную дробь
denominator = denominator / gcd;