Этот баннер — требование Роскомнадзора для исполнения 152 ФЗ.
«На сайте осуществляется обработка файлов cookie, необходимых для работы сайта, а также для анализа использования сайта и улучшения предоставляемых сервисов с использованием метрической программы Яндекс.Метрика. Продолжая использовать сайт, вы даёте согласие с использованием данных технологий».
Политика конфиденциальности
|
|
|
помогите мне с ошибками, пожалуйста!!!
|
|||
|---|---|---|---|
|
#18+
создание программу, реализующую алгоритм, преобразующий произвольное положительное число, записанное в арабских цифрах, в систему римских цифр и наоборот. #include <iostream> #include <string> using namespace std; int main(int argc, char* argv[]) { const int M = 1000; const int D = 500; const int C = 100; const int L = 50; const int X = 10; const int V = 5; const int I = 1; int nNum; cout<<"Input number: "; cin>>nNum; int nM = nNum/M; int nRemainM = nNum%M; int nD = nRemainM/D; int nRemainD = nRemainM%D; int nC = nRemainD/C; int nRemainC = nRemainD%C; int nL = nRemainC/L; int nRemainL = nRemainC%L; int nX = nRemainL/X; int nRemainX = nRemainL%X; int nV = nRemainX/V; int nRemainV = nRemainX%V; int nI = nRemainV; int i; for(i = 0; i < nM; i++) cout<<"M"; for(i = 0; i < nD; i++) cout<<"D"; for(i = 0; i < nC; i++) cout<<"C"; for(i = 0; i < nL; i++) cout<<"L"; for(i = 0; i < nX; i++) cout<<"X"; for(i = 0; i < nV; i++) cout<<"V"; for(i = 0; i < nI; i++) cout<<"I"; cout<<"\n"; return 0; } int get_arab_num(std::string rom_str) { int res = 0; for(size_t i = 0; i < rom_str.length(); ++i) { switch(rom_str[i]) { case 'M': res += 1000; break; case 'D': res += 500; break; case 'C': i + 1 < rom_str.length() && (rom_str[i + 1] == 'D' || rom_str[i + 1] == 'M') ? res -= 100 : res += 100; break; case 'L': res += 50; break; case 'X': i + 1 < rom_str.length() && (rom_str[i + 1] == 'L' || rom_str[i + 1] == 'C') ? res -= 10 : res += 10; break; case 'V': res += 5; break; case 'I': i + 1 < rom_str.length() && (rom_str[i + 1] == 'V' || rom_str[i + 1] == 'X') ? res -= 1 : res += 1; break; }//switch }//for return res; } int main() { std::string s; for(;;) { std::cout << "input roman num: "; std::cin >> s; std::cout << "arab num = " << get_arab_num(s) << std::endl << std::endl; } return 0; } ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 30.06.2013, 19:43 |
|
||
|
|

start [/forum/topic.php?fid=57&fpage=75&tid=2020116]: |
0ms |
get settings: |
7ms |
get forum list: |
11ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
46ms |
get topic data: |
10ms |
get forum data: |
2ms |
get page messages: |
33ms |
get tp. blocked users: |
1ms |
| others: | 300ms |
| total: | 416ms |

| 0 / 0 |
