|
|
back to boardThe solution is correct but test1 says it's wrong :/ Posted by Arusyak 16 Mar 2016 20:19 //Timus1493 #include <iostream> using namespace std; //Creates a copy and does not change the argument int sum_of_3(int num) { int result = 0;
for (int i = 1; i <= 3; i++) { result += num % 10; num /= 10; } return result; } int main () { int num; cin >> num;
int digit = num % 10, right = sum_of_3(num), left = sum_of_3(num / 1000);
if ((left > right && digit == 9) || (left < right && digit == 0)) cout << "No \n"; else cout << "Yes \n"; cout << num; return 0; } Re: The solution is correct but test1 says it's wrong :/ Fix output as task required - remove spaces after Yes and No, remove "cout << num;". |
|
|