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啊??谁帮忙看下好吗,想了很久都想不出不过的数据啊,附代码

Posted by 227368211 at 2009-11-18 18:26:46 on Problem 2159
#include<iostream>
#include<cstdlib>
#include<cstring>
using namespace std;
int cmp(const int *a,const int *b){
	if( *a > *b )
  return 1;
else if(*a < *b )
  return -1;
return 0;}
int main()
{int i,j,k,flag,len,len1=0,len2=0,s,a[2][150];
 char str[2][150];
 for(i=0;i<2;i++)
	 cin>>str[i];
 for(i=0;i<2;i++)
 {s=0;
  for(j=0;str[i][j]!='\0';j++)
	  if(str[i][j]!='0')
	  {flag=1;
	  for(k=j+1;str[i][k]!='\0';k++)
		  if(str[i][j]==str[i][k])
		  {flag++;
		  str[i][k]='0';}
		  a[i][s++]=flag;}}
for(i=0;a[0][i]>0;i++)
len1++;
for(i=0;a[1][i]>0;i++)
len2++;
if(len1==len2)
{len=len1;
qsort(a[0],len,sizeof(int),(int (*)(const void *, const void *))cmp);
 qsort(a[1],len,sizeof(int),(int (*)(const void *, const void *))cmp);
 for(i=0;i<len;i++)
 if(a[0][i]!=a[1][i])
	 {cout<<"NO"<<endl;
	 return 0;}
    cout<<"YES"<<endl;}
else
cout<<"NO"<<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