Hi:
I want to make a program that recognizes if a given number is "waving", that is, if it is of the form ababababa...
Nothing really comes into mind, any help is appreciated.
Hi:
I want to make a program that recognizes if a given number is "waving", that is, if it is of the form ababababa...
Nothing really comes into mind, any help is appreciated.
You can read the number as a string and process it that way.
You can convert the integer to a string and process it that way.
You can use the mod operator (% 10) to strip off the last digit one at a time.
Also consider:
* Is a single digit wavey?
* Are two digits wavey?
* Is a number wavey if a == b?
All truths are half-truths. - A.N. Whitehead
How can I read it as a string? I do not know the length of the number beforehand.
Are you taking input from the user? Then the number is a string when you read it, and you have to somehow convert it to an int or float during the input process.
Are you computing the number, or are you receiving the number as a parameter? Then you can use sprintf to write the number into a string buffer.