Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.82 KB | None | 0 0
  1.  
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #include <locale.h>
  5. #define N 30
  6.  
  7. int main()
  8. {
  9.     int A[N];
  10.     int l, lmax, i, min,n;
  11.     srand(time(0));
  12.     setlocale(LC_ALL, "RUS");
  13.  
  14.     printf("заполняем массив: \n");
  15.     for(i=0;i<N;++i)
  16.         A[i]=rand()%2000-1000;
  17.     for(i=0;i<N;++i)
  18.         printf("#%d %d\n",i+1,A[i]);
  19.  
  20.         l=1;
  21.         lmax=1;
  22.         min=10000;
  23.  
  24.     for (i=1;i<N;++i)
  25.     {
  26.         if(A[i]>0 && A[i+1]>0){
  27.             l++;
  28.             n=i;
  29.             }
  30.         else if(l>lmax){
  31.             lmax=l;
  32.             l=1;
  33.             min=10001;
  34.         }
  35.     }
  36.     printf("\nНайдена последовательность: ");
  37.     printf("%d,%d",lmax,n);
  38.     printf("\nМинимальное значение: ");
  39.     printf("%d",min);
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement