- 001
- 002
- 003
- 004
- 005
- 006
- 007
- 008
- 009
- 010
- 011
- 012
- 013
- 014
- 015
- 016
- 017
- 018
- 019
- 020
- 021
- 022
- 023
- 024
- 025
- 026
- 027
- 028
- 029
- 030
- 031
- 032
- 033
- 034
- 035
- 036
- 037
- 038
- 039
- 040
- 041
- 042
- 043
- 044
- 045
- 046
- 047
- 048
- 049
- 050
- 051
- 052
- 053
- 054
- 055
- 056
- 057
- 058
- 059
- 060
- 061
- 062
- 063
- 064
- 065
- 066
- 067
- 068
- 069
- 070
- 071
- 072
- 073
- 074
- 075
- 076
- 077
- 078
- 079
- 080
- 081
- 082
- 083
- 084
- 085
- 086
- 087
- 088
- 089
- 090
- 091
- 092
- 093
- 094
- 095
- 096
- 097
- 098
- 099
- 100
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define MAX 13
int main(void) {
void test_straight(int array[], int *flag ), test_flush(int array[], int array_2[]),
test_pair(int array[]), combi(int wDeck[][13]),
change_card( int array_suit[] , int array_face[] , int deck[][13] ), shuffle(int wDeck[][13]),
deal(int wDeck[][13], int gm_suit[], int gm_face[], int mg_suit[], int mg_face[]);
int find_combination(int array[], int array_2[], int flag);
int pc_suit[5], pc_face[5] , my_suit[5],my_face[5] , deck[4][13] = { 0 }, m = 0, w = 0,point = 0, f_1 = 0,a,e = 0, d = 0, f ;
const char *suit[4] = { "Hearts", "Diamonds", "Clubs", "Spades" };
const char *face[13] = {
"Deuce", "Three", "Four",
"Five", "Six", "Seven", "Eight",
"Nine", "Ten", "Jack", "Queen", "King","Ace"
};
combi(deck);
srand(time(0));
shuffle(deck);
deal(deck, my_suit, my_face, pc_suit, pc_face);
while(d != 5 ) {
point = find_combination(pc_face, pc_suit, 0 );
find_combination(my_face, my_suit, 0 );
puts("\t************************");
for (m = 0; m < 5; m++) {
printf(" %5s pc %8s <> %5s me %8s %d\n",face[pc_face[m]],suit[pc_suit[m]],face[my_face[m]],suit[my_suit[m]],m);
}
puts("\t************************\n");
while ( e != 5 ) {
puts("any button no change: change yes -1");
printf("%5s <> %8s", face[my_face[e]] , suit[my_suit[e]] );
scanf("%d", &a);
if(a == -1) {
my_face[e] = -1;
} else if(a == 7 ) {
break;
}
e++;
}
if(f_1 == 1 ) {
test_straight(pc_face ,&f_1 );
} else if(point < 40 ) {
switch(point) {
case 30:
case 20:
case 10:
test_pair( pc_face);
break;
case 0:
test_flush(pc_suit , pc_face );
change_card(pc_suit,pc_face,deck );
point = find_combination(pc_face, pc_suit,0 );
if(point == 50) {
break;
} else
test_straight(pc_face ,&f_1 );
break;
}
}
change_card(my_suit,my_face,deck );
change_card(pc_suit,pc_face,deck );
if(d <= 3) {
puts ("\n\t\tNEXT PART ");
}
d++;
e = 0;
}
point = find_combination(pc_face, pc_suit, 0);
if (find_combination(my_face, my_suit, 0 ) == point ) {
find_combination(my_face, my_suit, 1 ) > find_combination(pc_face, pc_suit, 1) || my_face[4] > pc_face[4] ? puts ("\n\t\t YOU WIN") : puts ( "\n\t\t YOU LOSE" );
} else {
find_combination(my_face, my_suit,0) > point ? puts ("\n\t\tYOU WIN ") : puts ( "\n\t\tYOU LOSE " );
}
puts("\t******** Game over ***********");
for (m = 0; m < 5; m++) {
printf(" %5s pc %8s <> %5s me %8s %d\n",face[pc_face[m]],suit[pc_suit[m]],face[my_face[m]],suit[my_suit[m]],m);
}
puts("\t******** Game over ***********");
return 0;
}
void test_flush( int array[] , int array_2[] ) {
int f = 0, d = 0 , r = 0, p = 0 , n = 1;
if(array[0] != array[1] && array[1] == array[2] && array[2] == array[3] && array[3] == array[4]) {
array_2[0] = -1;
} else
for (f = 0; f != 5; f++) {
for(d = 0 ; d != 5; d++) {
if(array [f] != array [d]) {
r++;
n = d;
} else {
p++;
}
}
if( p == 4 && r == 1 ) {
array_2[n] = -1;
break;
}
}
bayan 24.12.2016 01:58 # +1
риальне, это руками написано?