Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- string s;
- cin >> s;
- int zbir = 0;
- for(int i = 0; i < s.size(); i++) {
- zbir += s[i] - 48;
- }
- string res = "";
- for(int i = 0; i < s.size(); i++) {
- int cifra = s[i] - 48;
- for(int j = 0; j <= 9; j++) {
- if(cifra != j) {
- int tmp_zbir = zbir - cifra + j;
- if(tmp_zbir % 3 == 0) {
- string s2 = s;
- s2[i] = j + 48;
- res = max(res, s2);
- }
- }
- }
- }
- cout << res << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment