字母重排

来源:互联网 发布:mac 拷贝文件夹 命令 编辑:程序博客网 时间:2024/05/16 01:25
tarp given score refund only trap work earn course pepper part
******

resco nfudre aptr sett oresuc

#include <cstdio>#include <cstring>#include <algorithm>#include <iostream>#include <cmath>#include <queue>#include <map>#include <stack>#include <list>#include <vector>using namespace std;#define DEBUGint f=0;char c[1000][100],x[1000][10],k[1000][10];void ff(char s[10]){char ss[10];strcpy(ss,s);int l=strlen(s);for (int i=0; i<l; i++)for (int j=i+1; j<l; j++)if (s[i] > s[j]){char t=s[i];s[i]=s[j];s[j]=t;}strcpy(k[f++],s);strcpy(s,ss);//memset(&k[f++],s,sizeof(char));}int main(){#ifdef DEBUGfreopen("cin.txt", "r", stdin);freopen("cout.txt", "w", stdout);#endifchar s[10];while (~scanf("%s",x[f]) && x[f][0]!='*')ff(x[f]);int h=f;while (~scanf("%s",s)){ff(s);int fff=0;for (int i=0; i<h; i++){if (strcmp(k[i],k[f-1])==0){printf(" %s",x[i]);fff=1;}}if (fff==0) printf(":(");printf("\n");}return 0;}


0 0