Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <time.h>
- #include <locale.h>
- #define N 30
- int main()
- {
- int A[N];
- int l, lmax, i, min,n;
- srand(time(0));
- setlocale(LC_ALL, "RUS");
- printf("заполняем массив: \n");
- for(i=0;i<N;++i)
- A[i]=rand()%2000-1000;
- for(i=0;i<N;++i)
- printf("#%d %d\n",i+1,A[i]);
- l=1;
- lmax=1;
- min=10000;
- for (i=1;i<N;++i)
- {
- if(A[i]>0 && A[i+1]>0){
- l++;
- n=i;
- }
- else if(l>lmax){
- lmax=l;
- l=1;
- min=10001;
- }
- }
- printf("\nНайдена последовательность: ");
- printf("%d,%d",lmax,n);
- printf("\nМинимальное значение: ");
- printf("%d",min);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement