none
By: j00 | Date: Nov 19 2007 22:21 | Format: C++ | Expires: never | Size: 778 B | Hits: 1271
- #include <cstdlib>
- #include <iostream>
- #include <sstream>
- using namespace std;
- string convert(int decimal);
- string dectobin(int decimal);
- int main(int num)
- {
- int itemp;
- cout << "enter i: ";
- cin >> itemp;
- cout<< "enter n: ";
- cin>>num;
- string y;
- y = convert(num);
- cout << "n" << y << "n";
- system("PAUSE");
- return EXIT_SUCCESS;
- }
- string convert(int decimal)
- {
- return dectobin(decimal);
- }
- string dectobin(int decimal)
- {
- int r;
- string x;
- stringstream os;
- if (decimal<=0)
- {
- r = decimal % 2;
- dectobin(decimal/2);
- os <<r;
- x.append(os.str());
- }
- cout << x;
- return x;
- }
Latest pastes
1 days ago
2 days ago
4 days ago
6 days ago
6 days ago