Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <string>
- using namespace std;
- int main()
- {
- string str;
- int weight(0);
- ifstream ifs("roman.in");
- getline(ifs, str);
- ifs.close();
- for (int i = 0; i < str.length(); i++)
- {
- switch (str[i])
- {
- case 'I': weight += 1; break;
- case 'V': weight += 5; break;
- case 'X': weight += 10; break;
- case 'L': weight += 50; break;
- case 'C': weight += 100; break;
- case 'D': weight += 500; break;
- case 'M': weight += 1000; break;
- }
- }
- ofstream ofs("roman.out");
- ofs << weight;
- ofs.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment