I am supposed to write a program that takes the numbers of a file, finds the longest streak of ascending numbers, and returns the streak back. I am trying to find "streak" (or where the streak appears), but whenever I cout it returns as zero.
I know this is a hot mess, but here's what I have
int i = 0;
int j = 0;
int tryseq = 1;
int aseqcount = 0;
int streak = 0;
while (i < temp)
{
if (N[j].number < N[j+1].number)
{
tryseq++;
if (tryseq > aseqcount)
{
int aseqcount = tryseq;
int streak = j + 1;
}
else
int tryseq = 0;
}
j++;
i++;
}
aseqcount and streak return 0 every time I cout here but not in my tryseq > aseqcount.
Any ideas on how to fix this or is this way, way off base?
if (tryseq > aseqcount)
{
int aseqcount = tryseq; // here you're creating a new int variable in the if scope and hiding the original aseqcount variable declared above
int streak = j + 1; // ditto
}