日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Kattis-What does the fox say 字符串处理+STL

發(fā)布時間:2025/4/5 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Kattis-What does the fox say 字符串处理+STL 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

題目

The forest is, however, full of animals’ voices, and on your recording, many different sounds can be heard. But you are well prepared for your task: you know exactly all the sounds which other animals make. Therefore the rest of the recording—all the unidentified noises—must have been made by the fox.

Input
The first line of input contains the number of test cases T. The descriptions of the test cases follow:

The first line of each test case contains the recording—words over lower case English alphabet, separated by spaces. Each contains at most 100 letters and there are no more than 100 words. The next few lines are your pre-gathered information about other animals, in the format goes . There are no more than 100 animals, their names are not longer than 100 letters each and are actual names of animals in English. There is no fox goes … among these lines.

The last line of the test case is exactly the question you are supposed to answer: what does the fox say?

Output
For each test case, output one line containing the sounds made by the fox, in the order from the recording. You may assume that the fox was not silent (contrary to popular belief, foxes do not communicate by Morse code).

Sample Input 1 1 toot woof wa ow ow ow pa blub blub pa toot pa blub pa pa ow pow toot dog goes woof fish goes blub elephant goes toot seal goes ow what does the fox say?Sample Output 1 wa pa pa pa pa pa pow

思路

使用vector把第一行叫聲存入 再用set標(biāo)記出來每個animal的叫聲,然后判斷是否出現(xiàn)即可。
問題在于字符串的處理。

第一。
While(cin>>temp)可以連續(xù)輸入
退出的條件是:1.無效輸入,比如類型不同;2.遇到文件結(jié)束符(End_Of_FIle)。

第二。出現(xiàn)第一個goes作為第一行截止標(biāo)記。然后刪除goes前面的那個元素即可。

讀入第一行叫聲的代碼實現(xiàn)

while(cin>>temp){//輸入第一行 if(temp=="goes")//后面肯定有一個輸入,第一個叫聲 {cin>>temp;s.insert(temp);//存進(jìn)來v.pop_back();//goes之前有個無用的字符,刪除 break;}v.push_back(temp);//進(jìn)入向量 }

代碼

#include<bits/stdc++.h>using namespace std;int main() {int t;cin>>t;getchar();while(t--){vector<string> v;//存入第一行的叫聲 set<string> s;//標(biāo)記下面的叫聲 string temp;while(cin>>temp){//輸入第一行 if(temp=="goes")//后面肯定有一個輸入,第一個叫聲 {cin>>temp;s.insert(temp);//存進(jìn)來v.pop_back();//goes之前有個無用的字符,刪除 break;}v.push_back(temp);//進(jìn)入向量 }string animal,sound;//讀取animal goes sound while(cin>>animal>>temp>>sound){if(temp!="goes")//最有一句輸入沒用,有五個字符,全部吃掉{cin>>temp>>animal;break; }s.insert(sound);//sound 進(jìn)入set用作判斷 }for(size_t i=0;i<v.size();++i){if(s.find(v[i])==s.end())//在s中沒有找到則是fox 的叫聲 {cout<<v[i];if(i==v.size()-1) cout<<endl;else cout<<" ";}}}return 0; }

總結(jié)

以上是生活随笔為你收集整理的Kattis-What does the fox say 字符串处理+STL的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 亚洲欧洲中文字幕 | 色天堂在线视频 | 久久精品视频网站 | 婷婷色图 | 美女高潮流白浆视频 | 欧美日韩在线播放 | 黄色国产一区 | 欧美一区二区三区视频 | www.99热| 亚洲综合免费观看高清完整版 | 欧美性tv | 亚洲AV无码成人精品区东京热 | 中文字幕在线播放av | 精品欧美一区二区久久久 | 免费不卡av | 欧美s码亚洲码精品m码 | 亚州视频在线 | 狠狠人妻久久久久久综合 | 中文在线字幕观看 | 超碰在线人人 | 国产www免费| 91高清视频免费观看 | 可以看av| 波多野结衣一区二区三区在线 | 深夜福利网站在线观看 | 色开心 | 久久伊人网站 | 色在线视频观看 | 欧美成人一二区 | 国产草草 | 成人深夜福利 | 国产特级黄色录像 | 香蕉国产| 欧美日韩午夜 | 在线日韩亚洲 | 中文字幕人妻丝袜二区 | 啪免费视频 | 欧美在线一二三区 | 波多野结衣一二三四区 | 毛片天堂 | 警察高h荡肉呻吟男男 | 亚洲精品一区二区三区在线 | 亚洲成人久久精品 | 91久久人澡人人添人人爽欧美 | 亚洲欧美日韩在线看 | 国产做受69 | 一区二区三区天堂 | 免费超碰在线 | 好邻居韩国剧在线观看 | 日本白嫩的bbw | 国产麻豆网 | 麻豆免费观看视频 | 成年人福利 | 一级片免费在线观看 | 无码精品国产一区二区三区免费 | 国产另类专区 | 欧美日韩生活片 | 一区二区三区福利 | 国产精品国产三级国产专播品爱网 | 亚洲四虎av| 影音先锋久久 | 国产精品ww | 亚洲一区中文字幕在线观看 | 天堂伊人网 | 日本色影院 | 亚洲在线中文字幕 | 天堂在线免费观看 | 视频区小说区图片区 | 欧美一区二区三区成人久久片 | 蜜桃91麻豆精品一二三区 | 亚洲精品电影在线观看 | 韩国无码一区二区三区精品 | 手机在线观看日韩av | 男男受被啪到高潮自述 | 天堂av观看| 天天射综合 | 亚洲欧美国产高清va在线播放 | 亚洲欧美乱综合图片区小说区 | 国产成人一级 | 亚洲成人第一页 | h色视频在线观看 | 亚洲区综合 | 中文字幕av高清片 | 色xxxxxx| 在线午夜视频 | 免费看成人av| 丁香花激情网 | 国产精品久久久久久久久久久久久久久久 | 成人网免费看 | 亚洲精品一区二三区 | 精品韩国一区二区三区 | 久久夜色精品国产欧美乱极品 | 久久久久国产 | 91视频专区 | 亚洲免费网站在线观看 | 97se在线视频| 欧美一区二区三区黄色 | 自由成熟xxxx色视频 | 天天射天天干天天 |