国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

華為OJ:查找兄弟單詞

2019-11-08 02:15:12
字體:
來源:轉載
供稿:網友

查找兄弟單詞

輸入描述: 先輸入字典中單詞的個數,再輸入n個單詞作為字典單詞。 輸入一個單詞,查找其在字典中兄弟單詞的個數 再輸入數字n

輸出描述: 根據輸入,輸出查找到的兄弟單詞的個數

輸入例子: 3 abc bca cab abc 1

輸出例子: 2 bca

#include <cstdio>#include <string>#include <vector>#include <iostream>#include <algorithm>using namespace std;vector<string> dict;bool is_friend(string a, string b){ if (a == b) return false; sort(a.begin(), a.end()); sort(b.begin(), b.end()); return a == b;}int main(){ int n; while (scanf("%d", &n) == 1) { dict.clear(); for (int i = 0; i < n; i++) { string s; cin >> s; dict.push_back(s); } sort(dict.begin(), dict.end()); string ask; cin >> ask; int id; scanf("%d", &id); int cnt = 0; string res = ""; for (int i = 0; i < (int)dict.size(); i++) { if (is_friend(dict[i], ask)) { cnt++; if (cnt == id) { res = dict[i]; } } }
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 南涧| 新田县| 格尔木市| 朝阳市| 广灵县| 阜平县| 宽城| 茶陵县| 托里县| 阿拉善盟| 洱源县| 孝感市| 左贡县| 新昌县| 华亭县| 阿巴嘎旗| 黑河市| 新营市| 昔阳县| 丹凤县| 平舆县| 剑阁县| 镇巴县| 东莞市| 武冈市| 光泽县| 绥芬河市| 遵义市| 凌源市| 江安县| 库车县| 内丘县| 奉贤区| 宝应县| 无为县| 泽州县| 广灵县| 永春县| 正宁县| 龙井市| 土默特左旗|