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 476367795 at 2008-10-20 13:10:50 on Problem 1002
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;
string convert(string s);

int main()
{
	
	int m;
	cin>>m;
	if(m>100000)
		exit(0);

typedef string* stringPtr;
	stringPtr a;
	a=new string[m];
	


	int i;
	for (i=0;i<m;i++)
	{
		cin>>a[i];
		a[i]=convert(a[i]);
		
		
	}
	
	sort(a,a+m);
	
	int num,n;
	for (num=1,i=0; i<m-1; i=n)
	{
		
		while (a[i]==a[i+1])
		{
			num++;
			n=i+1;
			i++;
		}
		n++;
		if (num>=2)
		{
			string s="-";
			cout<<a[n-1].insert(3,s)<<" "<<num<<endl;
			num=1;
		}
	}
	
	return 0;
}


string convert(string s){
	      string s1;  

	for(int i=0;i<s.length();i++)
	{
			switch(s[i])
			{	case 'A': case 'B': case 'C': case '2':
						s1+= "2";
						break;
				case 'D': case 'E': case 'F':case '3':
						s1+= "3";
						break;
				case 'G': case 'H': case 'I': case '4':
						s1+= "4";
						break;
				case 'J': case 'K': case 'L': case '5':
						s1+= "5";
						break;
				case 'M': case 'N': case 'O': case '6':
						s1+= "6";
						break;
				case 'P': case 'R': case 'S': case '7':
						s1+= "7";
						break;
				case 'T': case 'U': case 'V': case '8':
						s1+= "8";
						break;
				case 'W': case 'X': case 'Y': case '9':
						s1+= "9";
						break;
				case '1':s1+= "1";break;
				case '0':s1+= "0";break;
				default :break;
			}
					
	}
	
    return s1;
}

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