标签:
1 class Solution { 2 public: 3 int romanToInt(string s) { 4 char temp; 5 int leng=s.length(); 6 for(int i=0;i<leng;i++){ 7 temp=s.at(i); 8 int number=charToInt(temp); 9 10 } 11 12 } 13 int charToInt(char c) 14 { 15 int num=0; 16 switch(c) 17 { 18 case ‘I‘:num=1; 19 break; 20 case ‘V‘:num=5; 21 break; 22 case ‘X‘:num=10; 23 break; 24 case ‘L‘:num=50; 25 break; 26 case ‘C‘:num=100; 27 break; 28 case ‘D‘:num=500; 29 break; 30 case ‘M‘:num=1000; 31 break; 32 } 33 return num; 34 } 35 };
标签:
原文地址:http://www.cnblogs.com/aguai1992/p/4620434.html