summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--snc.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/snc.c b/snc.c
index 723e64f..635e5b1 100644
--- a/snc.c
+++ b/snc.c
@@ -35,8 +35,15 @@ int romanToArabic(char *str)
amount_char = 1;
}
else if(last_value < cur_value) {
+ if(last_value * 10 < cur_value)
+ return -1;
+ else if(last_value == SNC_ROMAN_V ||
+ last_value == SNC_ROMAN_L || last_value == SNC_ROMAN_D)
+ return -1;
+
answer += cur_value - 2 * last_value;
- if(amount_char > 1) return -1;
+ if(amount_char > 1)
+ return -1;
amount_char = 1;
}
last_value = cur_value;