Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

String Problem

string

  • Please log in to reply
1 reply to this topic

#1 Hacker4life

Hacker4life

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 77 posts
  • Location:Serbia
  • Programming Language:C, C++, Delphi/Object Pascal, Pascal, Others
  • Learning:C, Java, C++, (Visual) Basic, Python, Delphi/Object Pascal, Pascal, Assembly, Others

Posted 13 August 2012 - 04:50 AM

The problem, my code fails at some point.
------------------
A. String Task

time limit per test2 seconds

memory limit per test256 megabytes

inputstandard input

outputstandard output

Petya started to attend programming lessons. On the first lesson his task was to write a simple program. The program was supposed to do the following: in the given string, consisting if uppercase and lowercase Latin letters, it:
  • deletes all the vowels,
  • inserts a character "." before each consonant,
  • replaces all uppercase consonants with corresponding lowercase ones.
Vowels are letters "A", "O", "Y", "E", "U", "I", and the rest are consonants. The program's input is exactly one string, it should return the output as a single string, resulting after the program's processing the initial string.
Help Petya cope with this easy task.

Input
The first line represents input string of Petya's program. This string only consists of uppercase and lowercase Latin letters and its length is from 1 to 100, inclusive.

Output
Print the resulting string. It is guaranteed that this string is not empty.
Sample test(s)

Input
tour


Output
.t.r


Input
Codeforces


Output
.c.d.f.r.c.s


Input
aBAcAba

Output
.b.c.b
{Code written by Hacker4life
May the Code be with you}
program A118;
var s:string;
i:integer;
begin
readln(s);
s:=LowerCase(s);
i:=1;
while i<length(s) do begin
			   if (s[i]='a')or(s[i]='o')or(s[i]='y')or(s[i]='i')or(s[i]='e')or(s[i]='u') then
									  begin delete(s,i,1); i:=i-1; end;
									  i:=i+1;

						   end;

	 i:=1;
	 repeat
	 insert('.',s,i);
	 i:=i+2;
	 until
	 i>length(s);
write(s);
end.

Example where it fails:
Input: aAaabaAa
my output: .b.a
Whats supposed to be the output: .b
Help?
  • 0

#2 Hacker4life

Hacker4life

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 77 posts
  • Location:Serbia
  • Programming Language:C, C++, Delphi/Object Pascal, Pascal, Others
  • Learning:C, Java, C++, (Visual) Basic, Python, Delphi/Object Pascal, Pascal, Assembly, Others

Posted 13 August 2012 - 05:20 AM

sorry, fixed it- mistake-
while i<length(s)+1 do begin
  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download