publicstaticStringbase2base(Stringn,intb1,intb2){
//Declarevariables:decimalvalueofn,
//characterofbaseb1,characterofbaseb2,
//andthestringthatwillbereturned.
intdecimalValue=0,charB2;
charcharB1;
Stringoutput="";
//Gothrougheverycharacterofn
for(inti=0;i9andstoreitincharB2
if(charB1>='A'&&charB1=10,addacharacterwiththe
//correspondingvaluetothenewnumber.(A=10,B=11,C=12,...)
else
output=(char)((decimalValue%b2)+55)+output;
//Dividebythenewbaseagain
decimalValue/=b2;
}
returnoutput;
}
这段代码中的intdecimalValue=0,charB2;为什么intdecimalValue=0,charB2;要加个逗号啊,和intdecimalValue=0;有什么区别...第一次见这种语法在github上看到的
分 -->
|