

Câu 1:Các boss tin giúp mk vs, mai ktra rồi mà mấy bài kiểu này còn gặm bútView attachment 107757
Var
M:array[1..100] of integer;
i,n,dau,ldau,dai,max:integer;
fi,fo:text;
Begin
Assign(fi,'dayso.inp');reset(fi);
Assign(fo,'dayso.out');rewrite(fo);
readln(fi,n);
For i:=1 to n do read(fi,M[i]);
i:=0;max:=1;dau:=1;dai:=1;ldau:=1;
While i<=n do
begin
i:=i+1;
If m[i+1]>=m[i] then dai:=dai+1
else if dai>max then
begin
max:=dai; ldau:=dau;dai:=0;
end
else Begin dau:=i+1;dai:=1;end;
end;
write(fo,max,' ',ldau);
Close(fi);close(fo);
End.
Nghe theo lời chị @nguyen tran thanh nha vậykhông giảm là có thể bằng nữa ấy nói chung là cứ sắp xếp tăng dần là ok thì phải
Var
fi,fo:text;
a:array[1..100] of integer;
i,n,tg,j:integer;
Begin
Assign(fi,'sn.inp');reset(fi);
Assign(fo,'sn.out');rewrite(fo);
readln(fi,n);
For i:=1 to n do read(fi,a[i]);
For i:=1 to n-1 do
For j:=i+1 to n do
if a[i]>a[j] then
begin
tg:=a[i];
a[i]:=a[j];
a[j]:=tg;
end;
For i:=1 to n do write(fo,a[i],' ');
Close(fi);Close(fo);
End.
Ko giảm là số trước [tex]a_{1}\leq a_{2}\leq ......a_{n}[/tex]Nghe theo lời chị @nguyen tran thanh nha vậy
Mã:Var fi,fo:integer; a:array[1..100] of integer; i,n,tg,j:integer; Begin Assign(fi,'sn.inp');reset(fi); Assign(fo,'sn.out');rewrite(fo); readln(fi,n); For i:=1 to n do read(fi,a[i]); For i:=1 to n-1 do For j:=i+1 to n do if a[i]>a[j] then begin tg:=a[i]; a[i]:=a[j]; a[j]:=tg; end; For i:=1 to n do write(fo,a[i],' '); Close(fi);Close(fo); End.
Chỗ chị khoanh vs sửa như này đúng ko e? Tại c thấy sai saiNghe theo lời chị @nguyen tran thanh nha vậy
Mã:Var fi,fo:integer; a:array[1..100] of integer; i,n,tg,j:integer; Begin Assign(fi,'sn.inp');reset(fi); Assign(fo,'sn.out');rewrite(fo); readln(fi,n); For i:=1 to n do read(fi,a[i]); For i:=1 to n-1 do For j:=i+1 to n do if a[i]>a[j] then begin tg:=a[i]; a[i]:=a[j]; a[j]:=tg; end; For i:=1 to n do write(fo,a[i],' '); Close(fi);Close(fo); End.
À, sửa vậy đúng rồi chị, em lộn, hay làm mảng A mà h đổi qua M nên lộnChỗ chị khoanh vs sửa như này đúng ko e? Tại c thấy sai saiView attachment 107792View attachment 107793