| ||||||||||
| 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 | |||||||||
我的~~~~~#include<string.h>
#include<stdlib.h>
#include<iostream.h>
long pow[10];
void pownum()
{
pow[0]=1;
pow[1]=9;
pow[2]=81;
pow[3]=729;
pow[4]=6561;
pow[5]=59049;
pow[6]=531441;
pow[7]=4782969;
pow[8]=43046721;
}
void main()
{
pownum();
while(1)
{
char s[10]="\0"; //一个8进制数的字符形式
char temp[10]="\0";
char ch;
int j=0,k=0;
while((ch=cin.get())!='\n')
{
temp[k++]=ch;
if(ch>='0'&&ch<='3') s[j++]=ch;
else s[j++]=char(int(ch)-1);
}
if(!strcmp(temp,"0"))break;
long value = 0;
int nLength = strlen(s);
// value+=int(s[nLength-1])-48;
for(int i=0;i<nLength;i++)
{
value+=pow[nLength-i-1]*(int(s[i])-48);
}
cout<<temp<<": "<<value<<endl;
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator