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

1A, 贴代码

Posted by 058179 at 2013-06-18 14:59:10 on Problem 1131
#include<iostream>
using namespace std;
#define MAX 100

char Number[MAX];
int temp[MAX];

int main()
{
	while(scanf("%s", &Number) != EOF)
	{
		int len = strlen(Number);
		memset(temp, 0, sizeof(temp));

		int pos = 0;
		for(int i = len - 1; i >= 2; i --)
		{
			int s = 0, j = 0;
			temp[0] = Number[i] - '0';

			while(j <= pos || s != 0)
			{
				s = s * 10 + temp[j];
				temp[j] = s/8;
				s%= 8;
				j ++;
			}
			pos = j - 1;
		}
		printf("%s [8] = 0.", Number);
		for(int k = 1; k <= pos; k ++) printf("%d", temp[k]);
		printf(" [10]\n");
	}
}

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