Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.37 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. //void max_seq(int*, int*, int*, int);
  4. void max_seq(int*, int**, int**, int);
  5.  
  6. int main(){
  7.          int *start;
  8.          int num = 0;
  9.          start = &num;
  10.           //start = 0;
  11.          int *end;
  12.         //end = 0;
  13.         end = &num;
  14.        
  15.         int arr[6] = {11,2,3,4,55,66};
  16.         //max_seq(arr,&start,&end, 6);
  17.         max_seq(arr, &start, &end, 6);
  18.                 printf("2.\nstart: %d\n end: %d\n", *start, *end);
  19.  
  20.         return 0;
  21. }
  22.  
  23. void max_seq(int*arr, int** start, int** end, int size){
  24. printf("ok");
  25.         int maxLenght = 0;
  26.         int count = 0;
  27.  
  28.         for(int i = 0; i < size-1; i++){
  29.                    
  30.                             *start = 0;
  31.                             *end = 0;
  32.                     if(*(arr+i) <= *(arr+i+1)){
  33.                             count++;
  34.  
  35.                             if(count > maxLenght){
  36.                                     *start += maxLenght - 1;
  37.                                     *end = *end + (maxLenght - 1)/*start*/ + count - 1;
  38.                                     maxLenght = count;
  39.                             }
  40.                     }else{
  41.                             count = 0;
  42.                     }
  43.     }      
  44. }
  45.  
  46. /*void max_seq(int* arr, int* start, int* end, int size){
  47.         int maxLenght = 0;
  48.         int count = 0;
  49.  
  50.         for(int i = 0; i < size-1; i++){
  51.                    
  52.                             *start = 0;
  53.                             *end = 0;
  54.                     if(*(arr+i) <= *(arr+i+1)){
  55.                             count++;
  56.  
  57.                             if(count > maxLenght){
  58.                                     *start += maxLenght - 1;
  59.                                     *end += *start + count - 1;
  60.                                     maxLenght = count;
  61.                             }
  62.                     }else{
  63.                             count = 0;
  64.                     }
  65.  
  66.  
  67.        
  68.     }
  69.         printf("1.\nstart: %d\n end: %d\nmaxLenght: %d\n", *start, *end, maxLenght);
  70. }*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement