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:新人做的~ 代码较长,麻烦大牛帮着看看~为什么总wrong呢

Posted by gdczcpy at 2011-02-06 14:02:01 on Problem 2159
In Reply To:新人做的~ 代码较长,麻烦大牛帮着看看~为什么总wrong呢 Posted by:Yiner at 2010-12-12 13:03:08
> #include<iostream>
> #include<cstring>
> using namespace std;
> char map[26]={'Z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y'};
> int main()
> { 
> 	 int flags[101];
> 	 int flag[101];
> 	 int flagss[101];
> 	 int flagsss[101];
> 	 int i,n,m,k,j,q;int z;
>      memset(flags,0,sizeof(flags));
>      memset(flag,0,sizeof(flag));
>      memset(flagss,0,sizeof(flagss));
>      memset(flagsss,0,sizeof(flagsss));
>    	 char str1[101];
> 	 char str2[101];
> 	 int a=0;
>      cin>>str1;
> 	 cin>>str2;
>       for(k=0;str1[k]!='\0';k++)
> 	  {
> 	    flag[str1[k]-'A']++;
> 	  }
> 	  for(j=0;str2[j]!='\0';j++)
> 	  {
> 	    flags[str2[j]-'A']++;
> 	  }
> 	  for(z=0;z<30;z++)
> 	  {
> 	   if(flags[z]!=flag[z])
> 	   { 		 
> 	   break; }
> 	  }
> 	  if(z==30)
> 		a=1;
>      for(i=0;str1[i]!='\0';i++)
> 	  {
> 	  str1[i]=map[str1[i]-'A'];
> 	  }  
> 	 for(n=0;str1[n]!='\0';n++)
> 	  {
> 	    flagsss[str1[n]-'A']++;
> 	  }
> 
> 	  for(m=0;str1[m]!='\0';m++)
> 	  {
> 	    flagss[str2[m]-'A']++;
> 	  }
> 	  for(q=0;q<30;q++)
> 	  {
> 		  if(flagss[q]!=flagsss[q])
> 		  {
> 		    break; 
> 		  }
> 	  }
> 	    if(q==30)
> 		    a=1;
> 
> 	  if(a==0)
> 		   cout<<"NO"<<endl;	 
> 	  else
> 		 cout<<"YES"<<endl;	  
> 	  return 0;
> }


AB
CD
YES

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