Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- void inputStr(string &x, int t, char sym) {
- x += '(';
- for (int i = 0; i < t; i++)
- x += sym;
- x += ')';
- }
- int main() {
- setlocale(LC_ALL, "Rus");
- string str;
- cout << "Введите строку: \n";
- cin >> str;
- int m;
- string ans;
- for (int i = 0; i < str.size(); i++) {
- if (isdigit(str[i])) {
- m = str[i] - '0';
- if (m % 2 == 0) {
- if (!m) m++;
- inputStr(ans, m, '+');
- } else
- inputStr(ans, m, '-');
- } else
- ans += str[i];
- }
- cout << ans << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement