UVA Solution 492 - Pig-Latin - Solution in C,C++ - Online Judge Solution

Latest

It is a free Online judges problems solution list. Here you can find UVA online Judge Solution, URI Online Judge Solution, Code Marshal Online Judge Solution, Spoz Online Judge Problems Solution

Monday, May 22, 2017

UVA Solution 492 - Pig-Latin - Solution in C,C++

UVA Solution 492 - Pig-Latin - Solution in C,C++

UVA Online Judge Solution 492 - Pig-Latin | Volume 4
UVA Problem Link - 492 - Pig-Latin solve

Problem Name: 492 - Pig-Latin solution
Problem Number : UVA - 492 - Pig-Latin code
Online Judge : UVA Online Judge Solution
Volume: 4
Solution Language : C plus plus

UVA Online Judge Solution, UVA OJ Solution list, UVA Problems Solution, UVA solver, UVA all problem solution list

UVA Solution 492 - Pig-Latin Code in CPP:

#include <stdio.h>
char s;
char stack[1000000];
int main() {
    int idx = 0;
    while(s = getchar()) {
        if(s == EOF)
            break;
            switch(s) {
                case 'a' ... 'z':
                    stack[idx++] = s;
                    break;
                case 'A' ... 'Z':
                    stack[idx++] = s;
                    break;
                default:
                    if(idx > 0) {
                        stack[idx] = '\0';
                        switch(stack[0]) {
                            case 'a':
                            case 'e':
                            case 'i':
                            case 'o':
                            case 'u':
                            case 'A':
                            case 'E':
                            case 'I':
                            case 'O':
                            case 'U':
                                printf("%say", stack);
                                break;
                            default:
                                printf("%s%cay", stack+1, stack[0]);
                        }
                        idx = 0;
                    }
                    putchar(s);
            }
    }
    return 0;
}


Tags: UVA Online Judge Solution, UVA OJ Solution list, UVA Problems Solution, UVA solver, UVA all problem solution list, UVA 492 - Pig-Latin  code in C, UVA 492 code in C++, UVA 492 - Pig-Latin solution in C, UVA 492 solution

No comments:

Post a Comment