Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

我的~~~~~

Posted by crest at 2007-05-19 17:08:20 on Problem 2719
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator