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

为什么一直WA,任何输入都正确啊,包括开头是0

Posted by bobovieri at 2010-07-08 00:08:01 on Problem 1002
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
int a;
string input;
string temp;

char cha[8];
char * stan(string a)
{
	for(int i=0;i<3;i++)
	{
	cha[i]=a[i];
	}

	cha[3]='-';

	for(int i=3;i<7;i++)
	{
	cha[i+1]=a[i];
	}
	
	return cha;
}
int main()
{

int sum;
cin>>sum;
string inpu;

vector<string>list;
for(int i=0;i<sum;i++)
{
	cin>>inpu;
	list.push_back(inpu);
	
}
//vector<string>list;
//sum=12;
//
//list.push_back("4873279");
//list.push_back("ITS-EASY");
//list.push_back("888-4567");
//list.push_back("3-10-10-10");
//list.push_back("888-GLOP");
//list.push_back("TUT-GLOP");
//list.push_back("967-11-11");
//list.push_back("310-GINO");
//list.push_back("F101010");
//list.push_back("888-1200");
//list.push_back("-4-8-7-3-2-7-9-");
//list.push_back("487-3279");


for(int j=0;j<sum;j++)
{
for(int i=0;i<list[j].size();i++)
{
	if((int)list[j][i]>=48&&(int)list[j][i]<=57) 
	{
		temp+=list[j][i];
	}

	else if(list[j][i]!='-'){

	switch(list[j][i])
	{
	case 'A':
	case 'B':
	case 'C':temp+='2'; break;
	case 'D':
	case 'E':
	case 'F':temp+='3'; break;
	case 'G':
	case 'H':
	case 'I':temp+='4'; break;
	case 'J':
	case 'K':
	case 'L':temp+='5'; break;
	case 'M':
	case 'N':
	case 'O':temp+='6'; break;
	case 'P':
	case 'R':
	case 'S':temp+='7'; break;
	case 'T':
	case 'U':
	case 'V':temp+='8'; break;
	case 'W':
	case 'X':
	case 'Y':temp+='9'; break;
	}
	}

}
list[j]=temp;
temp="";
}
std::sort(list.begin(),list.end());


vector<string> list1;
vector<int> list2;

int cot=1;
int cot1=0;
for(int i=0;i<sum;i++)
{
	for(int j=i+1;j<sum;j++)
	{
		if(list[i]==list[j])
		{
			list.erase(list.begin()+j);
				cot+=1;
				sum--;
				j--;
		
		}
	
	}
	if(cot!=1)
	{
	list1.push_back(list[i]);
	list2.push_back(cot);
	cot=1;
	cot1++;
	}
}

if(cot1==0)
{
	printf("No duplicates.\n");
}

else{

for(int i=0;i<cot1;i++)
{
	printf("%s", stan(list1[i]));
	printf(" %d",list2[i]);
	printf("\n");
}
}


system("pause");

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