打字练习
P5587 打字练习 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)
#include<iostream> #include<algorithm> #include<stack> #include<vector> #include<deque> using namespace std; long long ans=0; vector<string> a,b; deque<char> s,m; void read(vector<string> &a) { while(1) { string s; getline(cin,s); if(s=="EOF")break; a.push_back(s); } } void compa(string a,string b) { while(!s.empty())s.pop_front(); while(!m.empty())m.pop_front(); for(int i=0;i<a.length();i++) { if(a[i]=='<' && !s.empty())s.pop_back(); else if(a[i]=='<')continue; else s.push_back(a[i]); } for(int i=0;i<b.length();i++) { if(b[i]=='<' && !m.empty())m.pop_back(); else if(b[i]=='<')continue; else m.push_back(b[i]); } while(!s.empty() && !m.empty()) { if(s.front()==m.front())ans++; s.pop_front(); m.pop_front(); } } void comp(vector<string> h,vector<string> k) { for(vector<string>::iterator i=h.begin(),j=k.begin();i!=h.end() && j!=k.end();i++,j++) { compa(*i,*j); } } int main() { read(a); read(b); comp(a,b); double n; cin>>n; n/=60.0; cout<<(int)(ans*1.0/n+0.5); system("pause"); return 0; }
纯纯模拟,注意一下四舍五入的写法,不要写错
标签:string,read,while,int,12.1,vector,include From: https://www.cnblogs.com/bosssz/p/17869382.html