#include <stdio.h> #include <ctype.h> int test(char ch); int main() { int i; char ch; char root; int s; while(1){ i = 0; while(1){ ch = getchar(); if(ch == EOF) return 0; if(isalpha(ch)){ if(!i){ s = test(ch); if(s) printf("%c", ch); else root = ch; i++; }else{ printf("%c", ch); } }else{ if(!i){ printf("%c", ch); break; } if(s){ printf("ay%c", ch); }else{ printf("%cay%c", root, ch); } break; } } } return 0; } int test(char ch){ if(ch == 'A' || ch == 'a') return 1; if(ch == 'E' || ch == 'e') return 1; if(ch == 'I' || ch == 'i') return 1; if(ch == 'O' || ch == 'o') return 1; if(ch == 'U' || ch == 'u') return 1; return 0; }
Tuesday, July 31, 2012
ACM 492 -- Pig-Latin
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment