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

跪求大牛帮忙看看那里有问题......(附代码)

Posted by xxnan at 2011-04-14 11:36:16 on Problem 2629
#include<stdio.h>
#include<string.h>
#define N 2001
main()
{
   char a[N],b[N],s[N],t;
   int i,j,k,l1,l2,x,m;
   for(m=0;;m++)
       {  gets(a);gets(b);
	      k=0,x=0;
	      l1=strlen(a);
	      l2=strlen(b);
	      for(i=0;i<l1;i++)
	         {
			   for(j=0;j<l2;j++)
			     {
				    if(a[i]==b[j])
				   { 
				      s[k++]=a[i];break;
				   }
				 }
			 }
		  for(i=0;i<k-1;i++)
		    {
			  for(j=i+1;j<k;j++)
			    {
				   if(s[j]<=s[i])
				     {
					   t=s[j];
					   s[j]=s[i];
					   s[i]=t;
					 }  
				}  
			}
		  for(i=0;i<k;i++)
		    {
			   if(s[i]==s[i+1])
			   x++;
			}
		 if(x==k&&s[0]!=' ')
 		   printf("%c",s[0]);
 		 else
 		   {
			 for(i=0;i<k-1;i++)
			   {
			     if(s[i]!=s[i+1]&&s[i]!=' ')
			     printf("%c",s[i]);
			   }
			 printf("%c",s[k-1]);   
           }
           printf("\n");
	   }
	   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