no match for 'operator>' (operand types are 'std::__cxx11::string' {aka 'std::__cxx11::basic_string<char>'} and 'int')
Ostatnio zmodyfikowano 2020-12-05 19:55
niewiem123123 Temat założony przez niniejszego użytkownika |
no match for 'operator>' (operand types are 'std::__cxx11::string' {aka 'std::__cxx11::basic_string<char>'} and 'int') » 2020-12-05 19:28:45 Próbuję zrobić kod do konwertowania liczby w systemie czwórkowym na liczbę binarną, lecz w while(str>0) pojawia się problem w tytule. #include <iostream> #include <string> #include <sstream> using namespace std; int main() { string to_string( int a ); int a; cout << "Podaj liczbe w systemie czworkowym: "; cin >> a; stringstream ss; ss << a; string str = ss.str(); string b = ""; while( str > 0 ) { if( str % 2 == 0 ) b = '0' + b; else b = '1' + b; str = str / 2; } cout << "Liczba binarna: " << b; return 0; }
|
|
pekfos |
» 2020-12-05 19:55:05 Nie możesz porównać tekstu z liczbą, ani używać innych operacji arytmetycznych. Użyj typu liczbowego. |
|
« 1 » |