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

请问Runtime Error是什么问题

Posted by pphechuan at 2007-03-29 16:44:23
我的code 过不了1002,请帮帮忙啊。
#include<iostream>
#include<math.h>

using namespace std;
const maxn=10002;


int A[maxn];

void msort(int * F,int s,int t)
{
	int i,j,x;
	if (s>=t) return;
	i=s;
	j=t;
	x=F[s];
	while (i<j)
	{
		while ((F[j]>=x) && (i<j))
		{
			j--;
		}
		if(i<j) F[i]=F[j];
		while ((F[i]<=x) &&(i<j))
		{
			i++;
		}
		if(i<j) F[j]=F[i];
	}
	F[i]=x;
	msort(F,s,i-1);
	if (i==j)
		j=j+1;
	msort(F,j,t);
}
int main()
{
	int key[26] = {2,2,2,3,3,3,4,4,4,
         5,5,5,6,6,6,7,7,7,7,8,8,8,9,9,9,9,};
	int n;
	int num;
	int z;
	char t[100];
	cin>>n;
	for (int i=0;i<maxn;i++)
	{
		A[i]=0;
	}
	for (i=1;i<=n;i++)
	{
		num=0;
		cin>>t;
		z=strlen(t);
		for (int j=0;j<z;j++)
		{
			if ((t[j]>='0') && (t[j]<='9'))
			num=num*10+int(t[j])-48;
			if ((t[j]>='A') && (t[j]<='Y'))
			{
				num=num*10+key[t[j]-'A'];
			}
		}
		A[i]=num;
	}
	msort(A,1,n);
	i=1;
	int  x=0;
	while (i<=n)
	{
		int count;
		count=1;
		num=A[i];
		while ((i<n) && (A[i+1]==num))
		{
			i++;
			count++;
		}
		if (count>1)
		{
			x=1;
			for (int j=6;j>=4;j--)
			{

				cout<<num / int (pow(10,j));
				num=num % int (pow(10,j));
			}
			cout<<'-';
			for (j=3;j>=0;j--)
			{
				cout<<num / int (pow(10,j));
				num=num % int (pow(10,j));
			}
			cout<<" "<<count<<endl;
		}
		i++;
	}
	if(!x)
		cout<<"No duplicates."<<endl;
	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