lundi 5 mars 2018

Longest sequence of consecutive digits not using an array c++

I have an assignment to write a program that finds the longest ascending sequence. All of the examples I have looked up use arrays. We have not gone over arrays yet so I cannot use them. The assignment wants us to use for loops and if/else statements. I have worked with my classmates for a few hours and we have not been able to come up with solutions. So far we have found the length of the inputted number:

 if (x > 0)
    {
        for (len = 0; x > 0; len++)
        {
            x = x / 10;
        }
    }

Could anyone give us some guidance on what to do next?

Aucun commentaire:

Enregistrer un commentaire