Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- //void max_seq(int*, int*, int*, int);
- void max_seq(int*, int**, int**, int);
- int main(){
- int *start;
- int num = 0;
- start = #
- //start = 0;
- int *end;
- //end = 0;
- end = #
- int arr[6] = {11,2,3,4,55,66};
- //max_seq(arr,&start,&end, 6);
- max_seq(arr, &start, &end, 6);
- printf("2.\nstart: %d\n end: %d\n", *start, *end);
- return 0;
- }
- void max_seq(int*arr, int** start, int** end, int size){
- printf("ok");
- int maxLenght = 0;
- int count = 0;
- for(int i = 0; i < size-1; i++){
- *start = 0;
- *end = 0;
- if(*(arr+i) <= *(arr+i+1)){
- count++;
- if(count > maxLenght){
- *start += maxLenght - 1;
- *end = *end + (maxLenght - 1)/*start*/ + count - 1;
- maxLenght = count;
- }
- }else{
- count = 0;
- }
- }
- }
- /*void max_seq(int* arr, int* start, int* end, int size){
- int maxLenght = 0;
- int count = 0;
- for(int i = 0; i < size-1; i++){
- *start = 0;
- *end = 0;
- if(*(arr+i) <= *(arr+i+1)){
- count++;
- if(count > maxLenght){
- *start += maxLenght - 1;
- *end += *start + count - 1;
- maxLenght = count;
- }
- }else{
- count = 0;
- }
- }
- printf("1.\nstart: %d\n end: %d\nmaxLenght: %d\n", *start, *end, maxLenght);
- }*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement