tuki2501

dondieutang

Sep 4th, 2018
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.72 KB | None | 0 0
  1. uses crt;
  2. var
  3.   a:array[0..100000000] of longint;
  4.   i,n,c,s,tmp,max:longint;
  5.  
  6. procedure solve();
  7. begin
  8.   a[0]:=-2147483648;
  9.   for i:=1 to n do
  10.     begin
  11.       read(a[i]);
  12.       if a[i] >= a[i-1] then inc(tmp)
  13.       else
  14.         begin
  15.           if tmp>=2 then inc(c);
  16.           tmp:=1;
  17.         end;
  18.       if tmp>max then
  19.         begin
  20.           max:=tmp;
  21.           s:=i-max+1;
  22.         end;
  23.     end;
  24.   readln();
  25. end;
  26.  
  27. procedure display();
  28. begin
  29.   writeln('Co ',c,' day con lon hon mot phan tu!');
  30.   if c>=1 then
  31.     begin
  32.       writeln('Day con lon nhat la:');
  33.       for i:=s to s+max-1 do write(a[i],' ');
  34.     end;
  35. end;
  36.  
  37. begin
  38.   clrscr();
  39.  
  40.   readln(n);
  41.   solve();
  42.   display();
  43.  
  44.   readln();
  45. end.
Advertisement
Add Comment
Please, Sign In to add comment