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

Re:给几个数据给大家。借鉴

Posted by kaneLee at 2010-03-03 12:12:26 on Problem 1002
In Reply To:Re:给几个数据给大家。借鉴 Posted by:0815093 at 2010-01-28 21:57:31
> 没有炫耀的意思,我是来盖楼滴!
> #include <iostream>
> #include <string>
> #include <vector>
> #include <algorithm> // STL sort function
> using namespace std;
> 
> char map[] = "2223334445556667#77888999#";
> 			//ABCDEFGHIJKLMNOPQRSTUVWXYZ 
> void visited(char &ch) // visit and format strings
> {
>    if (ch >= 'A' && ch <= 'Z')
> 	   ch=map[ch-'A']; // ch equals to its real number
> }
> 
> int main()
> {
>     int N,i=0,j,flag=0;
> 	string s;
> 	vector<string> stored(100000); // be visited & stored (up to 100,000)
>     cin>>N;
> 	vector<int> counter(N,1); // stored times
>     
> 	for (; i<N; i++)
> 	{
> 		cin>>s;
> 		for (j=0; j<s.length(); j++) // MSDN
> 		{
> 			visited(s[j]);
> 			if (s[j]!='-')
> 			{
> 				stored[i] += s[j];
> 				if (stored[i].length()==3)
> 					stored[i] += '-'; // 487 -[3] 3279
> 			}
> 		}
> 	}
>     sort(stored.begin(),stored.begin()+N); // Quicker than QuickSort!
> 	// should not used stored.end() !
> 	i=0; j=1;
>     while (i<N)
> 	{
> 		while(stored[i] == stored[j])
> 		{
> 			counter[i]++;
> 			j++;
> 			flag=1;
> 		}
> 		i=j;
> 		j++;
> 	}
> 	
>     if (flag)
> 		for (i=0; i<N; i++)
> 		{
> 			if (counter[i]>1)
> 				cout<<stored[i]<<" "<<counter[i]<<endl;
> 		} // must have { }
> 	else 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