Last active
August 26, 2018 05:07
-
-
Save WindAzure/24330d94533753fc2dd2841f6b669d88 to your computer and use it in GitHub Desktop.
algorithm exercise
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 <math.h> | |
int main() | |
{ | |
auto T = 1; | |
auto a = 0, b = 0, c = 0; | |
while (~scanf("%d%d%d", &a, &b, &c)) | |
{ | |
if (a == 0 && b == 0 && c == 0) break; | |
printf("Case %d: %d", T++, a / b); | |
if (c == 0) { printf("\n"); continue; } | |
else { printf("."); } | |
auto remainderNum = a % b; | |
for (int i = 0; i < c - 1; i++) | |
{ | |
remainderNum *= 10; | |
printf("%d", remainderNum / b); | |
remainderNum %= b; | |
} | |
auto tail = remainderNum * 100 / b + 5; | |
printf("%d\n", tail / 10); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment