Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #define SIZE 12
- using namespace std;
- int main()
- {
- int i;
- int array[SIZE]= {3, 2, 1, 2, 3, 2, 1, 0, 1, 0, 2, 3};
- // int array[SIZE]= {1,2,3,4,5,6,7,8,9,10,11,12};
- int brel = 1, brred = 0, max = 1;//брой елементи на текуща редица, брой редици, дължина на най-дълга редица
- for(i =0 ; i< SIZE-1; i++)
- {
- if(array[i]>array[i+1])
- brel++;
- else
- {
- if(brel!=1)
- {
- cout<<"descending sequence with legth of "<<brel<<endl;
- if(brel>max) max=brel;
- brel = 1;
- brred++;
- }
- }
- }
- if(max==1)
- cout<<"no descending sequences";
- else
- {
- cout<<"number of descending sequences - "<<brred<<endl;
- cout<<"longest descending sequence with length of "<<max<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement