ALERT!
Click here to register with a few steps and explore all our cool stuff we have to offer!

Jump to content



Photo

[Help] I Have Some Problems


  • Please log in to reply
[Help] I Have Some Problems

#1

hungptit2015
hungptit2015
    Offline
    0
    Rep
    11
    Likes

    DarK_MonsTer

Posts: 16
Threads: 2
Joined: Sep 14, 2015
Credits: 0
Eight years registered
#1

Write a program that converts a natural number in base 10 into the system in any mechanical system of b ( 1 < b≤ 36 ) .
My code isn't working correct.

 

 

#include<iostream>
using namespace std;
void doicoso(int n, int c) {
if(n >= c) doicoso(n/c, c);
if(n%c > 9) 
cout << static_cast<char>(n%c+55);
else
cout << n%c;
}
main() {
int a,c;
cout << "Nhap so can chuyen: ";
cin >> a;
cout << "Nhap co so: ";
cin >> c;
while(c < 1  || c > 36){
cout << "Co so sai moi ban nhap lai!" <<  endl;
cin >> c;
}
doicoso(a,c);
}

Edited by hungptit2015, 14 September 2015 - 02:02 AM.

  • 1

#2

cocacola2015
cocacola2015
    Offline
    0
    Rep
    0
    Likes

    Lurker

Posts: 1
Threads: 0
Joined: Sep 14, 2015
Credits: 0
Eight years registered
#2

up


  • 0

#3

pruned_57632262
pruned_57632262
    Offline
    0
    Rep
    8
    Likes

    Member

  • PipPipPip
Posts: 26
Threads: 0
Joined: Sep 13, 2015
Credits: 0
Eight years registered
#3

ty


  • 0


 Users browsing this thread: