Skip to content

Instantly share code, notes, and snippets.

@lempiy
Created February 15, 2017 19:23
Show Gist options
  • Save lempiy/cbe62d76472f62eba0dbfcd1413fa527 to your computer and use it in GitHub Desktop.
Save lempiy/cbe62d76472f62eba0dbfcd1413fa527 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>

int get_coin (int number) {
    if (number >= 25) {
        return 25;
    } else if (number >= 10) {
        return 10;
    } else if (number >= 5) {
        return 5;
    } else {
        return 1;
    }
}

float init (float num) {
    int result = 0;
    int user_input = num * 100;
    while(user_input) {
        user_input = user_input - get_coin(user_input);
        result++;
    }
    return result;
}

int main () {
    float num;
    do {
        printf("Enter a number: ");
        scanf("%f",&num);
        if (num > 0) {
            int result = init(num);
            printf("%d\n", result);
        } else {
            printf("Watta fuck is this!?\n");
        }
    } while (num > 0);

    return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment