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 mixter at 2005-10-29 10:38:53 on Problem 1001
In Reply To:请教一下, Presentation Error?是出了什么错.以前好像没碰到过! Posted by:piratelzs at 2005-10-29 10:19:41
> #include <stdio.h>
> #include <memory.h>
> 
> char Result[125], Temp[125];
> unsigned char Tab[10][10][2];
> unsigned char s[6];
> 
> void MakeTab() //制造9 * 9乘法表
> {
> 	int i, j, aa;
> 	for (i = 0; i < 10; i++)
> 	{
> 		for (j = 0; j < 10; j++)
> 		{
> 			aa = i * j;
> 			Tab[i][j][0] = aa / 10;
> 			Tab[i][j][1] = aa % 10;
> 		}
> 	}
> }
> 
> void Caculate() //两个数组相乘机算
> {
> 	memset(Temp, 0, 125);
> 	int i, j;
> 	for (i = 1; i < 6; i ++)
> 	{
> 		for (j = 5; j < 125; j++)
> 		{
> 			if (0 != s[i] && 0 != Result[j])
> 			{
> 				Temp[i + j - 5] += Tab[s[i]][Result[j]][1];
> 				Temp[i + j - 6] += Tab[s[i]][Result[j]][0];
> 			}
> 		}
> 	}
> 	for (i = 124; i > 0; i--)
> 	{
> 		Temp[i - 1] += Temp[i] / 10;
> 		Temp[i] %= 10;
> 	}
> 	memcpy(Result, Temp, 125);
> }
> 
> void OutPut() //将结果输出
> {
> 	int i, aa, bb;
> 	for (i = 0; i < 125; i++)
> 	{
> 		if (0 != Result[i])
> 		{
> 			aa = i;
> 			break;
> 		}
> 	}
> 	for (i = 124; i > 0; i--)
> 	{
> 		if (0 != Result[i])
> 		{
> 			bb = i;
> 			break;
> 		}
> 	}
> 	if (-2 == Result[bb]) bb--;
> 
> 	for (i = aa; i <= bb; i ++)
> 	{
> 		printf("%c", Result[i] + 48);
> 	}
> }
> 
> int GetNumber() //将输入数组进行调整'.'放到最前面
> {
> 	int aa = 0, i;
> 	for (i = 5; i >= 0 ; i --)
> 	{
> 		if ('.' == s[i])
> 		{
> 			aa = 5 - i;
> 		}
> 		else s[i] -= 48;
> 	}
> 	for (i = 5; i > 0 ; i --)
> 	{
> 		if ('.' == s[i])
> 		{
> 			s[i] = s[i - 1];
> 			s[i - 1] = '.';
> 		}
> 	}
> 	return aa;
> }
> 
> void AdjustPos(int n)
> {
> 	int i;
> 	int bb = 124 - n;
> 	for (i = 1; i <= bb; i++)
> 	{
> 		Result[i - 1] = Result[i];
> 	}
> 	Result[bb] = '.' - 48;
> }
> 
> int main()
> {
> 	int n, nDotPos, i;
> 	MakeTab();
> 	while (2 == scanf("%s%d", s, &n))
> 	{
> 		nDotPos = GetNumber();
> 		memset(Result, 0, 125);
> 		memcpy(Result + 120, s + 1, 5);
> 		for (i = 1; i < n; i ++)
> 		{
> 			Caculate();
> 		}
> 		AdjustPos(nDotPos * n);
> 		OutPut();
> 	}
> 	return 0;
> }

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