int romanToInt(char * s){ int* hash = (int*)calloc(26,sizeof(int)); hash['I'-65] = 1; hash['V'-65] = 5; hash['X'-65] = 10; hash['L'-65] = 50; hash['C'-65] = 100; hash['D'-65] = 500; hash['M'-65] = 1000; int sum=0; for (int i=0; i<strlen(s)-1; i++) { sum+=(hash[s[i]-65] >= hash[s[i+1]-65])?hash[s[i]-65]:-hash[s[i]-65]; } sum+=hash[s[strlen(s)-1]-65]; return sum; }