NSBCoding
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Task 6: The cake is a lie!

Go down

Task 6: The cake is a lie! Empty Task 6: The cake is a lie!

Post  Admin Thu Jun 09, 2011 12:49 pm

WARNING: This task requires knowledge of how to read from a file using fscanf and fprintf.

You're at a party and there's cake. Actually, ONE cake. Now the dilemma is to split it into N pieces for each of the N guests. But obviously, cakes have integer sizes and thus cannot be split into decimal-sized pieces. So there's gonna be leftovers. To avoid minimal waste, you cut as much integer pieces as possible, leaving the least amount of leftovers. Given the size of the cake and the number of guests, calculate size of each piece and leftovers.

Input:
This task will require you to read from a file. The file will contain two integers, S and N. S is the size of the cake and N is the number of guests.

Output:
Print out the size of each piece, then the size of the left over as a fraction. If there's no leftovers, no fraction is required.

Example:
Input:
55 12
Output:
4 7/12

Input:
100 10
Output:
10

Admin
Admin

Posts : 21
Join date : 2011-06-04

https://nsbcoder.board-directory.net

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum