Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
karlki
/
IAX0583
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9779220e
authored
Oct 31, 2017
by
karlki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
blackjack.c
parent
09f0e942
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
90 additions
and
0 deletions
Praktikum 9/blackjack.c
Praktikum 9/blackjack.c
0 → 100644
View file @
9779220e
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int
main
(
void
)
{
srand
(
time
(
NULL
));
char
*
kaardid
[
13
]
=
{
"2"
,
"3"
,
"4"
,
"5"
,
"6"
,
"7"
,
"8"
,
"9"
,
"10"
,
"J"
,
"Q"
,
"K"
,
"A"
};
char
*
cV6etud
[
13
];
char
*
pV6etud
[
13
];
int
pCount
=
0
;
int
cCount
=
0
;
int
player
=
0
;
int
computer
=
0
;
int
i
=
0
;
int
lost
=
0
;
for
(;
i
<
2
;
i
++
)
{
cV6etud
[
i
]
=
kaardid
[(
rand
()
%
13
)];
pV6etud
[
i
]
=
kaardid
[(
rand
()
%
13
)];
pCount
++
;
cCount
++
;
}
for
(
i
=
0
;
i
<
2
;
i
++
)
{
if
(
cV6etud
[
i
]
==
"J"
||
cV6etud
[
i
]
==
"Q"
||
cV6etud
[
i
]
==
"K"
||
cV6etud
[
i
]
==
"A"
)
{
if
(
cV6etud
[
i
]
==
"A"
)
{
if
(
computer
==
11
)
{
computer
=
computer
+
1
;
}
else
{
computer
=
computer
+
11
;
}
}
else
{
computer
=
computer
+
10
;
}
}
else
{
computer
=
computer
+
atoi
(
cV6etud
[
i
]);
}
if
(
pV6etud
[
i
]
==
"J"
||
pV6etud
[
i
]
==
"Q"
||
pV6etud
[
i
]
==
"K"
||
pV6etud
[
i
]
==
"A"
)
{
if
(
pV6etud
[
i
]
==
"A"
)
{
if
(
player
==
11
)
{
player
=
player
+
1
;
}
else
{
player
=
player
+
11
;
}
}
else
{
player
=
player
+
10
;
}
}
else
{
player
=
player
+
atoi
(
pV6etud
[
i
]);
}
}
printf
(
"Arvuti: %d [ "
,
computer
);
for
(
i
=
0
;
i
<
cCount
;
i
++
)
{
printf
(
"%s "
,
cV6etud
[
i
]);
}
printf
(
"]
\n
"
);
printf
(
"Sina: %d [ "
,
player
);
for
(
i
=
0
;
i
<
pCount
;
i
++
)
{
printf
(
"%s "
,
pV6etud
[
i
]);
}
printf
(
"]
\n
"
);
if
(
player
==
21
)
{
printf
(
"Palju 6nne v6itsid arvutit!
\n
"
);
lost
=
1
;
}
if
(
computer
==
21
)
{
printf
(
"Arvuti v6itis, sa kaotasid!
\n
"
);
lost
=
1
;
}
while
(
lost
==
0
)
{
printf
(
"siin peaks programm t66tama!
\n
"
);
lost
=
1
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment