日韩性视频-久久久蜜桃-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)容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 怡红院成永久免费人全部视频 | 日本免费在线视频观看 | 18禁免费无码无遮挡不卡网站 | 超碰牛牛 | 黑人超碰 | 中文字幕美女 | 精品亚洲一区二区三区四区五区 | 亚洲av中文无码乱人伦在线视色 | 国产理论精品 | 欧美成一区二区三区 | 国产强被迫伦姧在线观看无码 | 日日鲁鲁鲁夜夜爽爽狠狠视频97 | www.久久久久久久 | 东京热一本视频一区 | 97超碰人人草 | 熟妇毛片 | 亚洲午夜一区 | 欧美中文视频 | 五月婷婷开心 | 免费日韩成人 | 免费人成视频在线播放 | av久久久 | 最新日韩av | 国产视频一区二区三区四区 | 在线观看免费福利 | 影音先锋人妻啪啪av资源网站 | 九久久| 与亲女洗澡时伦了毛片 | 亚洲成人av一区二区三区 | 五月婷婷天堂 | 亚洲av女人18毛片水真多 | 91视频播放器 | 成人一级影片 | 在线国产观看 | 日日嗨av一区二区三区四区 | 激情戏网站 | 午夜精品久久久 | 国产精品一区二区久久国产 | 日韩a毛片| 99re国产在线| 久久96 | 女女高潮h冰块play失禁百合 | 男人的天堂一区 | 精品视频一区二区三区在线观看 | 亚洲在线精品视频 | 国产一区二区三区18 | 夜夜导航| 久久不射视频 | 日日草日日干 | 禁断介护av | 少妇激情四射 | 粉嫩av懂色av蜜臀av分享 | 亚洲av久久久噜噜噜熟女软件 | 娇小萝被两个黑人用半米长 | 欧美用舌头去添高潮 | 兄弟兄弟全集免费观看 | 少女与动物高清版在线观看 | va在线看| 另类小说av | 国产又粗又深又猛又爽又在线观看 | 琪琪色av| 国产鲁鲁 | 成年人精品 | 亚洲精品乱码久久久久久蜜桃91 | 中文字幕人妻互换av久久 | 日本r级电影在线观看 | 4438x全国最大成人网 | 久草电影网站 | 国产美女在线观看 | 欧美性极品 | 成人免费在线视频 | 97精品视频| 亚洲欲妇| 日韩在线视频二区 | 在线三区 | 国产精品一区在线看 | 毛片91| 美日韩一区二区三区 | 一区二区在线免费看 | 欧美日韩精品综合 | 欧美激情在线狂野欧美精品 | 91这里只有精品 | 视频区小说区图片区 | 日韩avwww| 美女一二三区 | 欧美第一页浮力影院 | 开心激情综合网 | 国产精品12p | 国产精品免费精品一区 | 欧美大片在线看 | 777米奇影视第四色 五月丁香久久婷婷 | 无码国产精品一区二区高潮 | 亚洲蜜桃精久久久久久久久久久久 | 久久国产小视频 | 日韩不卡免费视频 | 亚洲国产欧美一区二区三区深喉 | 欧美韩一区二区 | 亚洲精品久久久久avwww潮水 | 一区二区三区不卡在线观看 |