- #include
- #include
- using namespace std;
-
- int main()
- {
- int relult = 0;
- int i=7;
- while( i >= 0)
- {
- char ch;
- cin >> ch;
- if( ch == '1' )
- {
- relult += (long int) pow( (float)2,(int)(i) );
- }
- i--;
- }
-
- cout << relult << endl;
- return 0;
- }
relult += pow( 2,i); 要改成relult += pow(2.0, i); 因为函数重载中没第一个参数是整形的重载函数。