Solution for CCC '02 J2 - AmeriCanadian in C++


April 10, 2020 0.012239 seconds C++
#include <iostream>
using namespace std;

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	string inp;
	int l;
	cin >> inp;
	while(inp != "quit!"){
			l = inp.length();
			if(l > 4 && inp[l - 1] == 'r' && inp[l - 2] == 'o' && !(inp[l - 3] == 'a' || inp[l - 3] == 'e' || inp[l - 3] == 'i' || inp[l - 3] == 'o' || inp[l - 3] == 'u' || inp[l - 3] == 'y')){
				
				cout << inp.substr(0, l - 2) << "our\n";
			}else{
				cout << inp << "\n";
			}
			
		cin >> inp;
	}
		
	return 0;
	}

Editorial


No editorial for this problem. :(

Original Problem


You can view the original page for this problem on the DMOJ.