1# include<iostream>2# include<string>3# include<cstring>4 using namespacestd;5 structbigint{//Define a large integer class6 inta[ -];7 intremain;8 inti;9BigInt &operator*(int& value) {//overloaded multiplicationTen for(i=0;i< -; i++) Onea[i]=a[i]*value; A intC=0; - for(i=0;i< -; i++){ -a[i]=a[i]+C; thec=a[i]/ -; -a[i]=a[i]% -; - } - return* This; + } - BOOL operator!=(Const int& value)//determines whether an integer is 0 + { A for(i=0;i< -; i++) at if(A[i]!=value) Break; - if(i< -)return true; - return false; - } -BigInt &operator/(int&value) {//Overloaded Division - intC=0; in for(i=499; i>=0; i--) - if(a[i]!=0) Break; to //cout<< "I" <<i<<endl; + for(; i>=0; i--) - { theA[i]= (a[i]+c* -); *c=a[i]%value; $a[i]=a[i]/value;Panax Notoginseng } -remain=C; the return* This; + } A }; the intMain () { + intm=0, n=0; - intI=0; $ while(cin>>m>>N) { $ strings; -Cin>>s; - if(s=="0") {cout<<0<<endl;Continue;} the intL=s.size (); - bigint Bida;Wuyimemset (BIDA.A,0,sizeof(BIDA.A)); the for(i=0; i<l;i++) - { Wu intk=m; - if(i!=0) bida=bida*K; About if(s[i]<='9') { $ intk=s[i]-'0'; -bida.a[0]=bida.a[0]+K; - } - Else { A intk=s[i]-'A'+Ten; +bida.a[0]=bida.a[0]+K; the } -}//Convert to decimal number Bida; $ //cout<<bida.a[0]; the intb[ -]; theI=0; thememset (b,0,sizeof(b)); the while(bida!=0){ -bida=bida/N; inb[i]=Bida.remain; thei++; the } About for(i=i-1; i>=0; i--) the { the if(b[i]>9) {Charc=b[i]-Ten+'a';cout<<C;} the Elsecout<<B[i]; + } -cout<<Endl; the }Bayi return 0; the}
It's a little messy, first pass. Go back and finish.
Nine degrees [1080] binary conversion