Today, I insisted on writing algorithms on the fifth day. Since I have never learned the c language, and I used mircrosoft c ++ 6.0, it was too difficult to use and so sad. After some column tests, the number system is finally converted. Still have a certain sense of accomplishment, hey.
Let's talk less about the code.
# Include "stdio. h"
# Include "math. h"
Void main (){
Int q, m, k, p, s [50];
Double n;
M = 0;
Printf ("\ n please input the decimal number n :");
Scanf ("% lf", & n); // enter % lf
Printf ("\ n please input the number of converted hexadecimal numbers p (2-16 ):");
Scanf ("% d", & p );
Printf ("(% f) 10 = (", n );
While (n! = 0 ){
Q = fmod (n, p );
N = floor (n/p );
M ++;
S [m] = q;
}
For (k = m; k> = 1; k --){
If (s [k]> 9 ){
Printf ("% c", s [k] + 55 );
}
Else {
Printf ("% d", s [k]);
}
}
Printf (") % d \ n", p); // The position must be placed after the for loop. Otherwise, the result is not output in one piece.
}
I want to learn the data structure today. I can use the stack to complete it. I will try it later.