- #1
trash
- 14
- 0
I'm working with this excercise: make a program that gives the number of consecutive letters of a word and the most repeated letter in a row -example: if i enter aaafdseergftth and i press return the program should return a = 3, e=2, t=2 and a=3-.
I've come up with a couple of "solutions", like define a string and then use an array to get the characters and compare then with a while loop, but here's the issue: i can't use arrays, string, sunbfunctions to solve this excersise, and explicitely says i have to look for another solution.
Now here is my second idea without using strings or arrays: Define an unknown amounts of char variables and enter each one until Intro is entered with a while loop like While not (Eoln) do (...). And that's the only thing i can come up right now to solve it, but when i was looking for a way to define an unknown amount of variables i found nothing but a solution with an array that i should resize to enter new variables.
The next attempt: i defined tree variables char and one int. Then i defined a While Not (Eoln) that checks every letter entered and compare it with the one before, that would almost solve the excercise. The issue is that every time i enter a letter the while loop will be triggered, then after the loop -after i enter return- i could only print the character of the last of consecutive row of letters -the while is needed because i want the result after i entered all the letters-. If i try with the example above i get: t = 2.
Any ideas?
I've come up with a couple of "solutions", like define a string and then use an array to get the characters and compare then with a while loop, but here's the issue: i can't use arrays, string, sunbfunctions to solve this excersise, and explicitely says i have to look for another solution.
Now here is my second idea without using strings or arrays: Define an unknown amounts of char variables and enter each one until Intro is entered with a while loop like While not (Eoln) do (...). And that's the only thing i can come up right now to solve it, but when i was looking for a way to define an unknown amount of variables i found nothing but a solution with an array that i should resize to enter new variables.
The next attempt: i defined tree variables char and one int. Then i defined a While Not (Eoln) that checks every letter entered and compare it with the one before, that would almost solve the excercise. The issue is that every time i enter a letter the while loop will be triggered, then after the loop -after i enter return- i could only print the character of the last of consecutive row of letters -the while is needed because i want the result after i entered all the letters-. If i try with the example above i get: t = 2.
Any ideas?