|
|
вернуться в форумC++ wrong answer test1 Послано hjkhg 30 ноя 2021 13:18 i checked it manually and answer was correct. Why does if fail? Code: #include <iostream> int main(){ std::string lock1, lock2; std::string result = "yes"; int code = 1; int lock_val1, lock_val2, cur_value; bool lock_state = false; std::cin>>lock1; std::cin>>lock2; lock_val1 = std::stoi(lock1); lock_val2 = std::stoi(lock2); while (code < 10000) { if (lock_state == true){ cur_value = lock_val1; } else{ cur_value = lock_val2; } if (code > lock_val1 && code > lock_val2){ result = "no"; break; } if (code == cur_value){ break; } lock_state = !lock_state; ++code; }
std::cout << result << std::endl; return 0; } Edited by author 30.11.2021 13:19 Edited by author 30.11.2021 13:19 Edited by author 30.11.2021 13:24 Edited by author 30.11.2021 13:37 Re: C++ wrong answer test1 Послано hjkhg 30 ноя 2021 13:38 It passed, there was a typo. |
|
|