| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
为什么我的WA啊??谁帮忙看下好吗,想了很久都想不出不过的数据啊,附代码#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator