Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main(int argc, const char * argv[])
- {
- int Quotient = 0, Remainer = 0 , n = 0, m = 0, result = 0, temp = 0;
- char PurchasedSticks[10] , NeededSticks[10];
- while(1)
- {
- scanf("%s",PurchasedSticks);
- scanf("%s",NeededSticks);
- n = atoi(PurchasedSticks);
- m = atoi(NeededSticks);
- if( n == 0 ) return 0; // End of input
- else
- {
- Quotient = n / m;
- Remainer = n % m;
- result = Quotient;
- while( (temp = Quotient + Remainer) >= m )
- {
- Quotient = temp / m;
- Remainer = temp % m;
- result += Quotient;
- }
- printf("%d\n",result);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment