UVA 12724 Hnelpig Arnde

这道题我犯了一个精神病一样的错误还在那里找的听HIGH



#include <iostream>

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <map>


using namespace std;


map<string,string> ma;
map<string,bool> p;
char str[55];
char str1[55];
char mess[100000+10];


int main()
{
    int t;
    int n,m;
    scanf("%d",&t);
    for( int i = 1; i<= t; i++)
    {
        printf("Case #%d:\n",i);
        scanf("%d %d",&n ,&m);
        for( int i = 0; i<n; i++)
        {
            cin>>str;
            strcpy(str1,str);
            sort(str1,str1+ strlen(str1));
            ma[str1] = str;
            p[str1] = true;
        }
        getchar();
        int k = 0;
        while( k < m)
        {
            gets(mess);
            char temp[55];
            int cnt = 0;
            for( int j = 0; ; j++)
            {
                 if(mess[j] != ' ' && mess[j] != '\0')
                   {
                      temp[cnt++] = mess[j];
                      continue;
                   }


                  temp[cnt] = '\0';
                 // cout<<temp<<endl;
                  cnt = 0;
                  sort(temp,temp + strlen(temp));
                  if(p[temp])
                   cout<<ma[temp];


                  if(mess[j] != '\0')
                   printf(" ");
                else
                {
                    printf("\n");
                    break;
                }
            }
          k++;
        }


    }
    return 0;
}

你可能感兴趣的:(UVA 12724 Hnelpig Arnde)