Skip to content

Instantly share code, notes, and snippets.

@henrybear327
Last active August 29, 2015 14:07
Show Gist options
  • Save henrybear327/2862a83aa0fe44907333 to your computer and use it in GitHub Desktop.
Save henrybear327/2862a83aa0fe44907333 to your computer and use it in GitHub Desktop.
Week 4 pc^2 project
#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