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:大牛们..路过帮看一下吧...无限WA

Posted by z_dream at 2010-05-19 23:01:24 on Problem 1002
In Reply To:大牛们..路过帮看一下吧...无限WA Posted by:DeanL at 2010-05-18 08:37:41
题目错了,当没有重复时,不输出任何东西
> #include<iostream>
> #include<algorithm>
> using namespace std;
> char tel[100];
> char flag[26] = "2223334445556667077888999";
> struct Array
> {
> 	char num[10];
> }
> data[110000];
> int operator < (Array const& arr1, Array const& arr2)   
> {   
>   return strcmp(arr1.num, arr2.num) < 0;   
> }
> void sa(int n)
> {
> 	int j  = -1, k = -1;
> 	while (k < 8)
> 	{
> 		j++;
> 		if (tel[j] == '-')
> 			continue;
> 		k++;
> 		if (k == 3)
> 		{
> 			data[n].num[k] = '-';
> 			k++;
> 		}
> 		if (tel[j] >= 'A' && tel[j] <= 'Z')
> 		{
> 			data[n].num[k] = flag[tel[j] - 'A'];
> 			continue;
> 		}
> 		data[n].num[k] = tel[j];
> 	}
> 	data[n].num[k] = '\0';
> }
> int main()
> {
> 	int n;
> 	int k = 1;
> 	int j = 0;
> 	int temp;
> 	cin >> n;
> 	for (int i = 0;i < n;i++)
> 	{
> 		cin >> tel;
> 		sa(i);
> 	}
> 	sort(data , data + n);
> 	while (j < n)
> 	{
> 		temp = j;
> 		j++;
> 		while (j < n && strcmp(data[j].num , data[temp].num) == 0)
> 			j++;
> 		if (j - temp > 1)
> 		{
> 			cout << data[temp].num << ' ' << j - temp << endl;
> 			k = 0;
> 		}
> 		if (k == 1)
> 		{
> 			cout << "No duplicates." << endl;
> 		}
> 	}
> 	system("pause");
> }

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