Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
uses crt;
var i,n,d:integer;
a:array[1..100] of integer;
begin
clrscr;
write('nhap so ptu:');readln(n);
for i:=1 to n do
begin
write('A[',i,']=');
readln(a[i]);
end;
for i:=1 to n do
begin
if i=1 then
if (a[i] <a[i+1])and(a[i] <a[n]) then d:=d+1;
if i =1 then
if (a[i] >a[i+1])and(a[i]>a[n]) then d:=d+1;
if i >1 then
if (a[i] <a[i+1])and(a[i]<a[i-1]) then d:=d+1;
if i >1 then
if (a[i] >a[i+1])and(a[i]>a[i-1]) then d:=d+1;
end;
if d=n then write('thoa man') else write('ko thoa man');
readln;
end.
(mong dc 5*+hay nhất)
Hãy giúp mọi người biết câu trả lời này thế nào?
/* _user_Capricoder_ */
// to heomois
#include <bits/stdc++.h>
using namespace std;
int n, a[100005];
int main()
{
ios::sync_with_stdio(0);
cout << "N = "; cin >> n;
for (int i = 0; i < n; ++i)
cout << "a[" << i + 1 << "] = ", cin >> a[i];
a[n] = a[0];
a[n + 1] = a[1];
for (int i = 1; i <= n; ++i)
{
if (a[i] < a[i + 1] && a[i] < a[i - 1])
continue;
if (a[i] > a[i + 1] && a[i] > a[i - 1])
continue;
cout << "NO";
return 0;
}
cout << "YES";
return 0;
}
Hãy giúp mọi người biết câu trả lời này thế nào?
Bảng tin