0

Why is this program a mistake? [7]

When i try the "poker hand" challenge (https://www.sololearn.com/coach/97?ref=app) in code coach i write a code like this: https://sololearn.com/compiler-playground/cBqSQmj9SJM8/?ref=app But somehow my code can't satisfy test case 6. What should i do to fix it?

13th Nov 2024, 3:15 AM
Celvien Kurniawan
Celvien Kurniawan - avatar
5 Answers
+ 3
Your code is far too cryptic for me to have any interest in reading your code. But I will GUESS two things: 1. You probably are not handling the number 10 properly. 2. The error message that appears when the code finishes could be a problem as well.
13th Nov 2024, 4:08 AM
Jerry Hobby
Jerry Hobby - avatar
+ 1
Jerry Hobby about that, i'm sorry about my code is hard to understand. Because in the value function i tried to integrate the logic of poker rank in one operation of loops.
13th Nov 2024, 3:43 PM
Celvien Kurniawan
Celvien Kurniawan - avatar
0
in your function "value", add a return 0; to cover the else branch of all your if statements. This fixes the error message and supplies the base return value of your function. int value(int a[]){ ... your codes... //add this before the closing brace return 0; } I also prettified the formatting so it would not be too hard to look at. https://sololearn.com/compiler-playground/cn9K4Opv7O9W/?ref=app
13th Nov 2024, 3:03 PM
Bob_Li
Bob_Li - avatar
0
Ah, i just found out that when i use input: 5S 2S 2H 3S 3C I get a core dump. Also i have updated the code (added some comment in value function to clarify its function process.) Sorry, if my code is hard to understand.
14th Nov 2024, 3:03 AM
Celvien Kurniawan
Celvien Kurniawan - avatar
0
5S 2S 2H 3S 3C get a core dump. but rearranging it to 3S 2S 5S 2H 3C does not result in a core dump the order of the cards seem to affect it.
14th Nov 2024, 3:44 AM
Bob_Li
Bob_Li - avatar