What sequence means and give me some suggestions

Click For Summary
SUMMARY

The discussion centers on creating a function named "sequence" in C that determines if a set of five playing cards forms a straight in poker. The valid sequence includes cards ranked from 2 to King, with Ace being flexible in its position. The first example provided, consisting of two of diamonds, four of clubs, six of hearts, three of hearts, and five of spades, correctly returns 1, indicating a sequence. In contrast, the second example, featuring two of spades, king of spades, ace of clubs, three of diamonds, and five of hearts, returns 0, as it does not form a valid sequence.

PREREQUISITES
  • Understanding of C programming language syntax and functions
  • Knowledge of poker hand rankings and terminology, specifically "straight"
  • Familiarity with boolean values and their implementation in C
  • Ability to manipulate arrays or lists in C to represent card values
NEXT STEPS
  • Research how to implement arrays in C to store card values
  • Learn about sorting algorithms in C to arrange card values for sequence checking
  • Study boolean logic in C to effectively return true or false values
  • Explore functions in C for handling user input and validating card entries
USEFUL FOR

C programmers, game developers, and anyone interested in implementing card game logic, particularly those focusing on poker game mechanics.

brad sue
Messages
270
Reaction score
0
Hi, please can someone help me with this.

I want to write a function sequence in C that returns 1 when a set of 5 cards appear in sequence ; 0 if not.

I don't understand very well what to do here.

the sequence is 2,3,4,5,6,7,8,9,10,jack,queen,king, with ace considered as either before 2 or after king as needed

For example the set of cards( given as follow):

two of diamonds
four of clubs
six of hearts
three of hearts
five of spades

must have sequence =1;


but for the set of cards:

two of spades
king of spades
ace of clubs
three of diamonds
five of hearts

must have sequnce =0


I give this second example since I do not understand why the sequence is 0 here.

Can someone explain me what sequence means and give me some suggestions to write the function called sequence??
Please do not use structure

Thank you for your time.
B
 
Technology news on Phys.org
A sequence would be a straight in Poker terminology. Meaning 5 cards whose values are one after the other. The first set is 2, 3, 4, 5, 6, a sequence, so you return 1. The second set is A, 2, 3, 5, K, not a sequence, so you return a 0. What you are returning is a boolean value. A 1 is a boolean value signifying "true", and 0 is boolean for "false".
The assignment seems pretty straightforward.
 
Last edited:

Similar threads

  • · Replies 7 ·
Replies
7
Views
3K
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 20 ·
Replies
20
Views
7K
Replies
5
Views
8K
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K