but when everyitme i submit, and the site test my code, then the site always say "Wrong answer on test 5". Test 5 maybe means line 5 (?). Is there anything wrong with my solution ? Thanks.
In line 7, you only need int w;
The problem described w as an integer between 1 and 100 for your own personal information; it doesn't affect the coding at all, and you don't need to initialize w here, since the cin in the next line does so. Other than that your code looks fine.