Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <string>
- int eng_to_dec(std::string s) {
- transform(s.begin(),s.end(),s.begin(), ::tolower);
- int sum = 0;
- for(int i = 0; i< s.length(); i++) {
- s = s.c_str();
- sum += s[i];
- }
- switch(sum) {
- case 438: return 0;
- case 322: return 1;
- case 346: return 2;
- case 536: return 3;
- case 444: return 4;
- case 340: return 6;
- case 545: return 7;
- case 529: return 8;
- case 327: return 10;
- }
- if (s[0] == 'f' && sum == 426)
- return 5;
- else if (s[0] == 'n' && sum == 426)
- return 9;
- }
- int main () {
- std::cout << "Input a string: ";
- std::string a;
- getline(std::cin,a);
- int res = eng_to_dec(a);
- std::cout << "The number is: " << res << std::endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement