求助,45分但感觉怎么测都对

P1827 [USACO3.4] 美国血统 American Heritage

不同getline换cin试一下
by Hawkfrost @ 2024-01-27 23:36:55


过了,getline可能会多读入,最好别用 ~~可以给个关注吗~~
by Hawkfrost @ 2024-01-27 23:39:33


``` #include<iostream> #include<string> using namespace std; void getstring(string ins,string pres) { int i; char ch; if (pres.length()==1 || pres.length()==0 ) { cout<<pres[0]; return; } ch=pres[0]; for (i=0;i<ins.length();i++) if (ins[i]==ch) break; if (i>0) getstring(ins.substr(0,i),pres.substr(1,i)); if (i<ins.length()-1) getstring(ins.substr(i+1),pres.substr(i+1)); cout<<ch; } int main() { int i; string ins,pres,posts; cin>>ins>>pres; getstring(ins,pres); cout<<endl; return 0; }
by Hawkfrost @ 2024-01-27 23:43:40


学到了 万分感谢 已关
by shihan @ 2024-01-29 15:18:58


|