#include<iostream> #include<string> //replace()函数的使用 int main() { string s; while (getline(cin, s)) { while (s.find("you") != -1) { s.replace(s.find("you"), 3, "we"); } cout << s<<endl; } return 0; } /* F:\temp\22495120.28650\Main.cc: In function 'int main()': F:\temp\22495120.28650\Main.cc:8: error: 'string' was not declared in this scope F:\temp\22495120.28650\Main.cc:8: error: expected ';' before 's' F:\temp\22495120.28650\Main.cc:10: error: 'cin' was not declared in this scope F:\temp\22495120.28650\Main.cc:10: error: 's' was not declared in this scope F:\temp\22495120.28650\Main.cc:10: error: 'getline' was not declared in this scope F:\temp\22495120.28650\Main.cc:14: error: 'cout' was not declared in this scope F:\temp\22495120.28650\Main.cc:14: error: 'endl' was not declared in this scope */ |
Double click to view unformatted code.