|
|
вернуться в форумwhats wrong with this code?it say wrong answer #include<iostream> using namespace std; int main() { int x, y; int sum1 = 0, sum2 = 0; char n = 'n'; cin >> x; int max = x + 1; int min = x - 1; for (int i = 0; i <3; i++) { y = max % 10; max = max / 10; sum1 += y; } for (int i = 0; i < 3; i++) { y = max % 10; max = max / 10; sum2 += y; } if (sum2 == sum1) { n = 'y'; }
y = 0; sum1 = 0; sum2 = 0; for (int i = 0; i <3; i++) { y = min % 10; min = min / 10; sum1 += y; } for (int i = 0; i <3; i++) { y = min % 10; min = min / 10; sum2 += y; } if (sum2 == sum1) { n = 'y'; } if (n=='n') { cout << "no"; } else { cout << "yes"; } return 0; } |
|
|