Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- string number,tempstring;
- int degree_start, degree_end, len,temp,temp2,temp3,temp4;
- string code = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- cout << "Type the number" << endl;
- cin >> number;
- cout << "Type the degree of the number" << endl;
- cin >> degree_start;
- cout << "Type the degree of the converted number" << endl;
- cin >> degree_end;
- len = number.length();
- temp =0;
- for (int c=1;c<=len;c++)
- {
- tempstring=number.substr(len-c+1,1);
- for(int d=1;d<=degree_start;d++)
- {
- if(tempstring==code.substr(d,1))
- temp2 = d;
- }
- temp = temp+(temp2-1)*(degree_start^(c-1));
- }
- tempstring = " ";
- if(temp == 0)
- tempstring = "0";
- while (temp)
- {
- temp3 = temp-degree_end*(temp/degree_end);
- tempstring = code.substr(temp+1,1) + tempstring;
- temp = temp/degree_end;
- if(temp < degree_end)
- {
- tempstring = code.substr(temp+1,1) + tempstring;
- temp = 0;
- }
- }
- cout << "Result:" << tempstring <<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement