I need an algorithm/code

My informatics teacher told me to do an algorithm/program which has to check if the number describes a hill shape(3681 is a hill; 24839 is not a hill)
closed account (z05DSL3A)
That's nice, try reading this:
http://www.cplusplus.com/forum/beginner/1/#msg1
I read it before posting. What's the problem? Should I not have said that this is my homework?
Anyway... I'm sorry if you think I can't post a decent thread.
closed account (z05DSL3A)
I'm sorry if you think I can't post a decent thread.

You really think that that is a decent thread?

I wait with bated breath to see what others come back with.
Why isn't it decent? Have I not explained myself well enough?
closed account (z05DSL3A)
Maybe describe what you mean by a hill shape, describe how you would determine if a number describes a hill shape. Say why 3681 is a hill and 24839 is not a hill. etc.
Oh, ok. Think of the y axis in the xOy axis system. 1 is the smallest number on the axis and 9 is the highest so for example 12345678987654321 would describe a hill shape.
A number is a hill number if the numbers before the highest (12345654321) are in ascending order and the numbers after the highest (12345654321) are in descending order.
Sorry for not being exact at first.
closed account (z05DSL3A)
So

previous digit is minus one
previous state is ascending

For each digit
{
    if current digit minus previous digit is greater than zero 
        current state is ascending
    else
        current state is descending
    
    if previous state is descending and current state is ascending
        is not a hill
        finish
    
    previous state is  current state
    previous digit is current digit
}
is a hill
finish      

Thanks a lot!
And sorry if I annoyed you :D
Topic archived. No new replies allowed.