Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace::std;
- int main() {
- ifstream fin("input.txt");
- ofstream fout("output.txt");
- string c;
- getline(fin, c);
- int num =0;
- int kost = 0;
- string res;
- for(int i(0);i < c.size();i++) {
- if (c[i] == '+') {
- res += c[i];
- continue;
- }
- if (isdigit(c[i])) {
- res += c[i];
- continue;
- }
- if ( (c[i] == ' ' || c[i] == '-' || c[i] == '(' || c[i] == ')') && res[res.size()-1]!=' ' && res[res.size() - 1] != '-' && num < 2) {
- res += ' ';
- num++;
- kost = res.size() + 1;
- continue;
- }
- }
- if (kost == 7) {
- res.insert(res.begin() + 10, '-');
- res.insert(res.begin() + 13, '-');
- }
- if (kost == 8) {
- res.insert(res.begin() + 10, '-');
- res.insert(res.begin() + 13, '-');
- }
- if (kost == 9) {
- res.insert(res.begin() + 10, '-');
- res.insert(res.begin() + 13, '-');
- }
- if (kost == 10) {
- res.insert(res.begin() + 10, '-');
- res.insert(res.begin() + 13, '-');
- }
- if (kost == 11) {
- res.insert(res.begin() + 12, '-');
- }
- fout << res;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement