Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C++ by s110062238 ( 4 years ago )
#include <bits/stdc++.h>
#include "13485.h"
using namespace std;
using sc = String_Calculator;
sc tmp;
sc &o = tmp;
sc::String_Calculator(const string x){
    s = s+x;
}
sc& sc::Add(const string x){
    o.s = s + x;
    return o;
}
sc& sc::DividedBy(const string x){
    o.s = x;
    int s_len = s.length(), x_len = x.length(), cnt = 0;
    for (int i = 0; i <= s_len - x_len; i++){
        int j;
        for (j = 0; j < x_len; j++)
            if (s[i+j] != x[j]) break;
        if (j == x_len) cnt++;
    }
    o.s.clear();
    o.s = to_string(cnt);
    return o;
}
sc& sc::Subtract(const string x){
    size_t found = s.find(x);
    if (found < string::npos){
        s.erase(found, x.length());
        o.s = s;
        return o;
    }
    else{
        o.s = "error";
        return o;
    }
}
void sc::output() const{
    cout << s << '\n';
}

 

Revise this Paste

Your Name: Code Language: