Hi, I am trying to solve 118A - Упражнение на строки and the output I have in my pc is different than the output in codeforces. My submission:26568938
# | User | Rating |
---|---|---|
1 | jiangly | 3640 |
2 | Benq | 3593 |
3 | tourist | 3572 |
4 | orzdevinwang | 3561 |
5 | cnnfls_csy | 3539 |
6 | ecnerwala | 3534 |
7 | Radewoosh | 3532 |
8 | gyh20 | 3447 |
9 | Rebelz | 3409 |
10 | Geothermal | 3408 |
# | User | Contrib. |
---|---|---|
1 | maomao90 | 173 |
2 | adamant | 164 |
3 | awoo | 161 |
4 | TheScrasse | 160 |
5 | nor | 159 |
6 | maroonrk | 156 |
7 | SecondThread | 152 |
8 | pajenegod | 146 |
9 | BledDest | 144 |
10 | Um_nik | 143 |
Hi, I am trying to solve 118A - Упражнение на строки and the output I have in my pc is different than the output in codeforces. My submission:26568938
Name |
---|
Why I am downvoted like that?
declare str1 and str2 as global variable ;) 26571652
Thank you very much ^_^ , I really appreciate your help, but if you know can you please tell me why the output has changed ? or what was the issue ? Thank you again :)
I think unintitialized string is undefined behavior (UB) so anything could happen. Different compliers (even in same compliers) may generate different outputs. In order to avoid this problem, You can initialize the array elements to 0 by declare as global or static variables.
Just give
str2
an initializer likechar str2[101] = {0};
is OK.But in competitive programming it's recommended to declare large arrays static/global to avoid stack overflow. This array is small enough and Codeforces is using -Wl,--stack=xxxxxxxxxx so this won't happen.