ACM (UVa) : 492


RTE
RTE
RTE
i.e. Run time error

if u use gets () function or scanf () or any other function to store the whole input at once and after that try to process it, u will get the same reply from robot judge: RTE !!!

perhaps, the reason is, the input text is too big to store in any an array we plan/guess to declare, whether it is 1 million or 10 million elements !! so, get the input as character by character

let, character variable Ch continue (Ch = getcharacter ()) // in C/C++ it would be getchar () function if (Ch is equals to EOF) then, return otherwise, check its vowel or not follow the procedure

// remember one thing, the input text may not consist with only alphabet. So, in every step check whether it’s alphabet or not

// another thing, “A word is defined as a consecutive sequence of letters”

Critical input:
united 19
Pagol,Pola
23 35 52
… … …

Critical output:
uniteday 19
agolPay,olaPay
23 35 52
… … …

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define Max 1000000

int vowel (char X) // whether argument vowel or not
{
	if (X==65 || X==69 || X==73 || X==79 || X==85 || X==97 || X==101 || X==105 || X==111 || X==117)
		return 1;
	return 0;
}

int main ()
{
	char Save, C;

	while (C = getchar ()) {

	    if (C == EOF)
	    return 0;

		if (isalpha (C)) {
			if (vowel (C)) {
				while (isalpha (C)) {
					printf("%c", C);
					C = getchar ();
				}
				printf("ay");
			}

			else {
				Save = C;
				C = getchar ();
				while (isalpha (C)) {
					printf("%c", C);
					C = getchar ();
				}
				printf("%cay", Save);
			}
		}
		printf("%c", C);
		//printf("\n");
	}
	return 0;
}
Advertisements

2 thoughts on “ACM (UVa) : 492

  1. Tausiq vai
    ei problem tate ki every input case er pore blank line printf korte hobe naki hobena.
    cuz i’m getting PE.

  2. @Anas,
    ei problem tate ektai input case ase
    mane holo, program ta ekta case input nibe and setar output diye terminate korbe
    kono blankline/newline print korte hobe na

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s