I have seen in many people's code that they use a solve function instead of writing the logic in the main function. What advantage it has over writing the code directly in the main function?
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | maomao90 | 163 |
2 | Um_nik | 163 |
4 | atcoder_official | 161 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | nor | 153 |
9 | Dominater069 | 153 |
I have seen in many people's code that they use a solve function instead of writing the logic in the main function. What advantage it has over writing the code directly in the main function?
Название |
---|
You can use return directly in solve() in case there are test cases, while in int main() you can't
"continue" keyword is also there.
but you have to use many breaks statements too if you want to end the current test case from a loop
i just use goto statement to go back to the starting of the test case loop, is that less efficient?
Actually you can use
goto
but that would make spaghetti codeI personally use it because you can easily end the function with return(end).
I think it doesnt have obvious advantages. But many people are used to it since it looks comfortable. After all, the choice is up to you.
https://discuss.codechef.com/t/why-solve/54680/13
It's good to split everything in functions
.
.
She probably changed her name as a joke. Danil is a famous Youtuber, well known for his staring contest videos (Google him if you don’t believe me). Definitely not her.
.
.
I've googled but found nothing, can you provide the link?
Isn't it too obvious? Asking everything sucks
What is there in it to downvote except colortag?
Exactly
But u know people will downvote this too...
I know
I think because this is a common question so people should first google search before asking in blogs.
You decide.
And I decide that trump is a good president.
.....................................................................................
.