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

用G++能过的程序用C++竟然不能过,晕!!

Posted by caonimama at 2007-04-12 15:15:38 on Problem 1002
#include<iomanip.h>
#include<string.h>
#include<stdio.h>
#include<algorithm>
using namespace std;
char b[300],c[300],d[40]="22233344455566677778889999";
int a[200005];
int main()
{
	int n,i,j,k=0,kk=0,number,nn;
	cin>>n;
	for(i=0;i<n;i++)
	{
		scanf("%s",&b);k=0;
		int len=strlen(b);
		for(j=0;j<len;j++)//将乱码转化成字符串
		{
			if(b[j]>='0'&&b[j]<='9')
			{
				c[k++]=b[j];
			}
			else
				if(b[j]>='A'&&b[j]<='Z')
				{
					c[k++]=d[b[j]-'A'];
				}
			
		}
		number=0;nn=1;
		for(j=0;j<7;j++)//将字符串转化为整数
		{ 
			for(k=0;k<(6-j);k++)
			{
				nn*=10;
			}
			number+=(c[j]-'0')*nn;
			nn=1;
		}
		a[kk++]=number;//将整数存入数组,kk计算数的个数
	}
	k=0;nn=1;int count=1;number=0;a[kk]=99999999;
	sort(a,a+kk+1);//将数组中的数进行快速排序
	for(i=0;i<kk+1;i++)//将数据进行输出
	{
		if(a[i+1]==a[i])
		{
			count++;
		}
		else
		if(count>=2)
		{
			for(j=0;j<7;j++)
			{
				nn=1;
				for(k=0;k<(6-j);k++)
				{
					nn*=10;
				}
				if(j==3)
				{
					cout<<'-'<<a[i]/nn;
				}
				else
				{
					cout<<a[i]/nn;
				}
				a[i]-=(a[i]/nn)*nn;
			}
			cout<<" "<<count<<endl;
	    	count=1;
			number=1;
		}
	}
	if(number==0)
	{
		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