Όχι, δεν το μεταβάλει (αυτό εννοώ όταν λέω δεν το πειράζει).
Χαίρομαι που είμαστε ΟΚ με τα macros, enum και typedef

Ορίστε κι ο κώδικας για το... μπαρμπούτι που λέγαμε

Δεν κάνω πλάκα, σοβαρά είναι ένα απλοποιημένο μπαρμπούτι. Εξάρες, έξι-πέντε, πεντάρες, τριάρες κερδίζουν, άσοι, ασό-δυο, διπλές και ντόρτια χάνουν και σε όλα τα υπόλοιπα ξαναπαίζεις.
Επειδή είναι συγκεκριμένο το παιχνίδι, δουλεύει με 2 και μόνο ζάρια και όλη η ιστορία του είναι ο 2-διάστατοσ πίνακας Status tabstatus[6][6] που ουσιαστικά περιέχει όλους τους 36 πιθανούς συνδυασμούς (6χ6 = 36 κελιά) με τον καθένα τους να περιέχει LOSE, WIN ή AGAIN, ανάλογα με τον συνδυασμό που αντιπροσωπεύει το κάθε κελί

- Κώδικας: Επιλογή όλων
#include <stdlib.h>
#include <time.h>
#define MAXINBUF 255+1
#define NDICE 2 // ΥΠΟΧΡΕΩΤΙΚΑ ΝΑ ΕΙΝΑΙ 2
#define MAX_DIEVAL 6 // ΥΠΟΧΡΕΩΤΙΚΑ ΝΑ ΕΙΝΑΙ 6
#define STATUS_MAX_TXTLEN (20+1)
typedef enum status { LOSE=0, WIN, AGAIN } Status;
// ------------------------------------------------------------------------------------
char *s_ncopy( char *dst, const char *src, int n )
{
char *ret = dst;
while ( (dst-ret) < n-1 && (*dst=*src) != '\0' )
dst++, src++;
if ( *dst )
*dst = 0;
return ret;
}
// ---------------------------------------------------------------------------
int throw_dice( int *dice, const int ndice, const int maxval,
const Status tabstatus[maxval][maxval] )
{
dice[0] = rand() % maxval + 1;
dice[1] = rand() % maxval + 1;
return tabstatus[ dice[0]-1 ][ dice[1]-1 ];
}
// ---------------------------------------------------------------------------
char *status2text( char *text, const Status tabstatus )
{
if (tabstatus == AGAIN)
s_ncopy(text, "play again", STATUS_MAX_TXTLEN);
else if ( tabstatus == WIN )
s_ncopy(text, "you win!", STATUS_MAX_TXTLEN);
else if ( tabstatus == LOSE )
s_ncopy(text, "you loose!", STATUS_MAX_TXTLEN);
else
text = NULL;
return text;
}
// ---------------------------------------------------------------------------
int main( void )
{
char inbuf[ MAXINBUF ] = "";
const int ndice = (NDICE != 2 ? 2 : NDICE);
int bet = 0, dice[ ndice ];
char txtstatus[ STATUS_MAX_TXTLEN ] = "";
Status status;
const Status tabstatus[MAX_DIEVAL][MAX_DIEVAL] = {
/*+1/+1 0 1 2 3 4 5 */
/* 0 */ LOSE, LOSE, AGAIN, AGAIN, AGAIN, AGAIN,
/* 1 */ LOSE, LOSE, AGAIN, AGAIN, AGAIN, AGAIN,
/* 2 */ AGAIN, AGAIN, WIN, AGAIN, AGAIN, AGAIN,
/* 3 */ AGAIN, AGAIN, AGAIN, LOSE, AGAIN, AGAIN,
/* 4 */ AGAIN, AGAIN, AGAIN, AGAIN, WIN, WIN,
/* 5 */ AGAIN, AGAIN, AGAIN, AGAIN, WIN, WIN
};
srand( time(NULL) );
puts("To exit type x, or anything else to throw the dice");
do {
printf("> ");
fgets(inbuf, MAXINBUF, stdin);
if (*inbuf == 'x')
break;
status = throw_dice( dice, ndice, MAX_DIEVAL, tabstatus);
printf("Dice thrown: %d %d\n", dice[0], dice[1]);
printf("\t%s\n", status2text( txtstatus, status ) );
} while ( status != LOSE );
return 0;
}