#include<stdio.h> #include<string.h> int main() { char a[120][20]={"i","ii","iii","iv","v","vi","vii","viii","ix","x","xi","xii","xiii","xiv","xv","xvi","xvii","xviii","xix","xx","xxi","xxii","xxiii","xxiv","xxv","xxvi","xxvii","xxviii","xxix","xxx","xxxi","xxxii","xxxiii","xxxiv","xxxv","xxxvi","xxxvii","xxxviii","xxxix","xl","xli","xlii","xliii","xliv","xlv","xlvi","xlvii","xlviii","xlix","l","li","lii","liii","liv","lv","lvi","lvii","lviii","lix","lx","lxi","lxii","lxiii","lxiv","lxv","lxvi","lxvii","lxviii","lxix","lxx","lxxi","lxxii","lxxiii","lxxiv","lxxv","lxxvi","lxxvii","lxxviii","lxxix","lxxx","lxxxi","lxxxii","lxxxiii","lxxxiv","lxxxv","lxxxvi","lxxxvii","lxxxviii","lxxxix","xc","xci","xcii","xciii","xciv","xcv","xcvi","xcvii","xcviii","xcix","c"}; int num,i,j; while(scanf("%d",&num)==1) { if(num==0) { break; } int c1=0,c2=0,c3=0,c4=0,c5=0; for(i=0;i<num;i++) { for(j=0;j<strlen(a[i]);j++) { if(a[i][j]=='i') c1++; else if(a[i][j]=='v') c2++; else if(a[i][j]=='x') c3++; else if(a[i][j]=='l') c4++; else if(a[i][j]=='c') c5++; } } printf("%d: %d i, %d v, %d x, %d l, %d c\n",num,c1,c2,c3,c4,c5); } return 0; }
Tuesday, October 4, 2011
uva : 344- Roman Digititis
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment