Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int * nums = nullptr;
- int num;
- int n;
- int i, j, longest=1, len;
- // input order of array then allocate mem
- cin >> n;
- nums = new int[n];
- // input each num of sequence the store in array
- for (i = 0; i < n; i++)
- {
- cin >> num;
- nums[i] = num;
- }
- // do the thang
- for(i=0; i<n; i++){
- len=1;
- for(j=i; j<n; j++){
- if(nums[j+1]>nums[j]){
- len++;
- }
- }
- if(len>1 && len>longest){
- longest=len;
- }
- }
- delete[] nums;
- // if final value of len was 1, then no sequence exists.
- if (longest == 1)
- longest = -1;
- cout << longest << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement