#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    1
    Rep Power
    0

    Help with inputs


    Hey All
    I've just started learning the C programming language at uni and am in need of some help.

    If I have a input such as "3H 6S KH 7D AC"

    Is there a way to group the second and first terms in the input e.g

    First terms= 3,6,K,7,A
    Second terms= H,S,H,D,C

    Also is there a way to give the letters numerical values within the source code such as

    J=11
    Q=12
    K=13

    Any help would be appreciate my knowledge of C is very basic
    Thanks
    Murock
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,997
    Rep Power
    481

    Assign numeric value to card representation.


    Code:
    if (('2' <= CARD) && (CARD <= '9')) VALUE = CARD - '2';
    else if ('T' == CARD) VALUE = 8;
    else if ('J' == CARD) VALUE = 9;
    else if ('Q' == CARD) VALUE = 10;
    else if ('K' == CARD) VALUE = 11;
    else if ('A' == CARD) VALUE = 12;
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo