Thursday, 5 February 2015

C++ Program to find the Longest Increasing Series

C++ Program to find the Longest Increasing Series

#include<iostream.h>
#include<conio.h>
void main()
{
 int no,temp,i;
 int temp2=0;
 int max=0;
 int j=0;
 clrscr();
 cout<<"Enter 10 number to check longest:\n";
 for(i=1;i<=10;i++)
  {
   cin>>no;
   if(no>max)
    {
     max=no;
     j=j+1;
     temp=j;
    }
    else
     {
      j=1;
      if(temp2<temp)
      {
       temp2=temp;
      }
      max=no;
     }
   }
     if(temp2>j)
     cout<<"Longest series is: "<<temp2;
     else
     cout<<"Longest series is: "<<j;

   getch();
}

No comments:

Post a Comment