Commit 2e861166 by tonis2

Add bank resources

parent c2360412
No preview for this file type
#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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment