fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. void displayMidfix(const std::string &a)
  6. {
  7. size_t length = a.length();
  8. size_t middle = length/2;
  9.  
  10. string c = a.substr(middle-1, 3);
  11.  
  12. cout << "Midfix: " << c << endl;
  13. }
  14.  
  15. int main()
  16. {
  17. string a;
  18. while (cin >> a) {
  19. displayMidfix(a);
  20. }
  21. return 0;
  22. }
Success #stdin #stdout 0.01s 5408KB
stdin
flags xxxtoyxxx cat
stdout
Midfix: lag
Midfix: toy
Midfix: cat