Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
tanton
/
programmeerimine_1
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
2e861166
authored
Sep 10, 2020
by
tonis2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add bank resources
parent
c2360412
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
12 deletions
panga_automaat/automaat
panga_automaat/automaat.c
panga_automaat/automaat
View file @
2e861166
No preview for this file type
panga_automaat/automaat.c
View file @
2e861166
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <string.h>
#include <stdlib.h>
#define SUMMA 100
#define SUMMA 100
int
is_correct_choice
(
char
user_answer
[
3
])
{
char
new
[
3
];
struct
resource
{
int
amount
;
int
size
;
};
// struct bank_resources
// {
// int five;
// int twenty_five;
// int fifty;
// int hundred;
// };
// Kontrollib kas kasutaja vastas soovitud vastusega
int
is_correct_choice
(
char
user_answer
[
8
])
{
char
new
[
8
];
strcpy
(
new
,
user_answer
);
strcpy
(
new
,
user_answer
);
return
(
strcmp
(
new
,
"no"
)
==
0
)
||
(
strcmp
(
new
,
"yes"
)
==
0
);
return
(
strcmp
(
new
,
"no"
)
==
0
)
||
(
strcmp
(
new
,
"yes"
)
==
0
);
}
}
// int withdraw_from_lowest(struct resource data) {
// int return_amount = 0;
// if (data.five > 0) {
// data.five -= 1;
// return_amount = 5;
// }
// else if (data.twenty_five > 0) {
// data.twenty_five -= 1;
// return_amount = 25;
// }
// else if (data.fifty > 0) {
// data.fifty -= 1;
// return_amount = 50;
// }
// else if (data.hundred > 0) {
// data.hundred -= 1;
// return_amount = 100;
// }
// }
int
main
(
void
)
int
main
(
void
)
{
{
struct
resource
bank
[
4
];
bank
[
0
].
amount
=
rand
()
%
2
;
bank
[
0
].
size
=
5
;
bank
[
1
].
amount
=
rand
()
%
3
;
bank
[
1
].
size
=
25
;
bank
[
2
].
amount
=
rand
()
%
2
;
bank
[
2
].
size
=
50
;
bank
[
3
].
amount
=
rand
()
%
2
;
bank
[
3
].
size
=
100
;
char
user_answer
[
3
];
char
user_answer
[
8
];
int
return_total
=
0
;
printf
(
"Kas soovite väikseid kupüüre? ( yes / no )
\n
"
);
printf
(
"Kas soovite väikseid kupüüre? ( yes / no )
\n
"
);
scanf
(
"%s"
,
user_answer
);
scanf
(
"%s"
,
user_answer
);
int
user_choice
=
is_correct_choice
(
user_answer
);
int
user_choice
=
is_correct_choice
(
user_answer
);
printf
(
"Vastus %d
\n
"
,
user_choice
);
// while (*is_correct_choice != 1) {
while
(
user_choice
!=
1
)
// printf("Kas soovite väikseid kupüüre? ( yes / no ) \n");
{
// scanf("%s", user_answer);
//Laseme kasutajal uuesti vastata
// user_choice = is_correct_choice(user_answer);
printf
(
"Vale vastus !
\n
"
);
// }
printf
(
"Kas soovite väikseid kupüüre? ( yes / no )
\n
"
);
scanf
(
"%s"
,
user_answer
);
user_choice
=
is_correct_choice
(
user_answer
);
}
//Anname suuri kupüüre
if
(
strcmp
(
user_answer
,
"no"
)
==
0
)
{
if
(
is_correct_choice
==
0
)
{
printf
(
"Vastus %s
\n
"
,
is_correct_choice
);
}
}
// printf("Vastus %s \n", user_answer);
//Anname väikseid kupüüre
if
(
strcmp
(
user_answer
,
"yes"
)
==
0
)
{
printf
(
"Vastus %d
\n
"
,
user_choice
);
}
return
0
;
return
0
;
}
}
\ No newline at end of file
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