poj 1318 Word Amalgamation

  1. #include <iostream>  
  2. #include <string>  
  3. #include <vector>  
  4. #include <algorithm>  
  5. using namespace std;  
  6.   
  7. vector<string> v;  
  8.   
  9. int main()  
  10. {  
  11.     int size, i;  
  12.     string str, temp;  
  13.     while (cin >> str)  
  14.     {  
  15.           if (str == "XXXXXX")  break;  
  16.           v.push_back(str);  
  17.     }  
  18.     sort(v.begin(), v.end());  
  19.     bool flag;  
  20.     size = v.size();  
  21.     while (cin >> str)  
  22.     {  
  23.           if (str == "XXXXXX")  break;  
  24.           sort(str.begin(), str.end());  
  25.           flag = false;  
  26.           for (i = 0; i < size; i++)  
  27.           {  
  28.               temp = v[i];  
  29.               sort(temp.begin(), temp.end());  
  30.               if (temp == str)  
  31.               {  
  32.                    flag = true;  
  33.                    cout << v[i] << endl;  
  34.               }  
  35.           }  
  36.           if (flag)  
  37.               cout << "******" << endl;  
  38.           else   
  39.              cout << "NOT A VALID WORD" << endl << "******" << endl;  
  40.     }  
  41.       
  42.     return 0;
  43. }   
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值