Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int main () {
- char str[100];
- int cs=1;
- while (scanf("%s", str)) {
- if (str[0] == '#') return 0;
- int n = strlen(str) - 1;
- int zero = 1, ambi = 0, up = 0, down=0, no=0, doshomik = 0;
- for (; n>=0 ; n--) {
- if (str[n] == '.') {
- doshomik = 1;
- break;
- }
- else if (str[n] != '0' && zero == 1) {
- zero = 0;
- if (str[n] == '5') ambi++;
- else if (str[n] >= '0' && str[n] <= '4') down++;
- else up++;
- }
- else if (str[n] == '0') no++;
- else if (str[n] >= '0' && str[n] <= '4') down++;
- else up++;
- }
- printf("Case %d:\n", cs++);
- if (doshomik) {
- printf("ROUND UP: %d\n", up);
- printf("ROUND DOWN: %d\n", down);
- printf("NO CHANGE: %d\n", no);
- printf("AMBIGUOUS: %d\n", ambi);
- }
- else {
- printf("ROUND UP: %d\n", 0);
- printf("ROUND DOWN: %d\n", 0);
- printf("NO CHANGE: %d\n", 0);
- printf("AMBIGUOUS: %d\n", 0);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment