Jump to content

How to delete duplicated letters in turbo pascal?

WooZ_Lv

Can someone tell how to delete duplicated letters in turbo pascal?

Input - lllliiinnnuuussssttteeeccchhhtttiiipppsss

Output - linustechtips

Link to comment
Share on other sites

Link to post
Share on other sites

declare a string or an array of chars

declare a tmp char variable

loop through each letter, keep a tmp variable of the previous letter. if the previous letter is different than the current letter, append that letter in your result variable (or put the char in the char array) and put the current char into the tmpchar variable. Output the result variable.

Link to comment
Share on other sites

Link to post
Share on other sites

declare a string or an array of chars declare a tmp char variable loop through each letter' date=' keep a tmp variable of the previous letter. if the previous letter is different than the current letter, append that letter in your result variable (or put the char in the char array) and put the current char into the tmpchar variable. Output the result variable.[/quote']

Can you please write code for that?

Link to comment
Share on other sites

Link to post
Share on other sites

Why, is it a homework assignment and you want me to do it ? Post what you have done so far and I'll tell you what is wrong.

Start here to know how to declare variable : http://www.ee.ui.ac.id/~astha/courses/daskom/tutp1.html

Then look here (Example 8) to see how you can loop through a string : http://math.uww.edu/~harrisb/courses/cs171/strings.html

It's pretty close to your exact answer, except instead of removing a, b and c, you will only keep the letters that aren't repeating (using the technique I mentioned in my first post).

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×