Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
帮忙找错吧?why wa?谢了!#include<iostream> #include<cstring> #include<cmath> using namespace std; int main() { char str[8],result[50]; int b1,b2,i,len,temp,num,flag,tt; while(cin>>str>>b1>>b2) { temp=0;flag=0; len=strlen(str); for(i=0;i<len;i++) { if(str[i]>='A')num=str[i]-55; else num=str[i]-48; temp+=num*pow(b1,len-i-1); } while(temp>b2) { tt=temp%b2; temp=temp/b2; if(tt>9)result[flag++]=tt+55; else result[flag++]=tt+48; } if(temp>9)result[flag]=temp+55; else result[flag]=temp+48; if(flag+1>7)cout<<" ERROR"<<endl; else { for(i=0;i<=6-flag-1;i++)cout<<" "; for(i=flag;i>=0;i--)cout<<result[i]; cout<<endl; } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator