Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int size;
- printf("Enter array size: ");
- scanf("%d", &size);
- int a[size],len[size],i,j,max=0;
- printf("Enter the elements:\n");
- for(i=0;i<size;i++)
- {
- scanf("%d", &a[i]);
- }
- for(i=0; i<size; i++)
- {
- len[i]=0;
- }
- len[0] = 1;
- for (i=1;i<size;i++)
- {
- for (j=0;j<i;j++)
- {
- if (len[i]<len[j] && a[i]>a[j])
- {
- len[i]=len[j];
- }
- }
- len[i]++;
- }
- for(int i = 0; i<size; i++)
- {
- if(max<len[i])
- {
- max=len[i];
- }
- }
- printf("Length: %d",max);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement