Last active
August 29, 2015 14:07
-
-
Save henrybear327/2862a83aa0fe44907333 to your computer and use it in GitHub Desktop.
Week 4 pc^2 project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int main() | |
{ | |
int bars, coupon; | |
while(scanf("%d", &bars) != EOF) | |
{ | |
coupon = bars; | |
while(coupon >= 7) | |
{ | |
bars = bars + (coupon / 7); | |
coupon = coupon % 7 + coupon / 7; | |
//coupon left = the mod of the coupon plus the coupon acquired from redeeming. | |
} | |
printf("You can buy %d bars and will have %d unused coupon(s).\n", bars, coupon); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment