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

ac

Posted by zfeagle at 2012-09-03 20:45:12 on Problem 1318
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
int main()
{
    int l,i,l1,flag;
    char s[1000][1000],s1[1000],s2[1000][1000],s3[1000];
    i=0;
    while(1)
    {
        scanf("%s",s[i]);
        if(strcmp(s[i],"XXXXXX")==0)
        break;
        i++;
    }
        for(int j=0;j<i;j++)
            for(int k=j+1;k<i;k++)
        {            
            if(strcmp(s[j],s[k])>0)
            {
                 strcpy(s3,s[j]);
                 strcpy(s[j],s[k]);
                 strcpy(s[k],s3);                       
            }        
        }
        for(int j=0;j<i;j++)
        {
        strcpy(s2[j],s[j]);        
        l=strlen(s[j]);
        sort(s[j],s[j]+l);
        }    
             while(1)
             {
                  scanf("%s",s1);
                  if(strcmp(s1,"XXXXXX")==0)
                  break;
                  flag=0; 
                  l1=strlen(s1);
                  sort(s1,s1+l1);
                  for(int j=0;j<i;j++)
                  {
                      if(strcmp(s1,s[j])==0)
                      {
                      printf("%s\n",s2[j]); 
                      flag++;
                      }       
                  }
                  if(flag!=0)
                  printf("******\n");
                  if(flag==0)
                  printf("NOT A VALID WORD\n******\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