Những câu hỏi liên quan
Hương Bùi
Xem chi tiết
Nguyễn Lê Phước Thịnh
3 tháng 12 2021 lúc 22:03

#include <bits/stdc++.h>
using namespace std;
const long long maxint=1e6;
long long a[maxint],i,n,ln;
int main()
{
    cin>>n;
    for (i=1; i<=n; i++)
        cin>>a[i];
    ln=a[1];
    for (i=1; i<=n; i++)
        ln=max(ln,a[i]);
    for (i=n; i>=1; i--)
        if (ln==a[i])
    {
        cout<<i;
        break;
    }
    return 0;
}

 

Bình luận (0)
Huy Hoàng Phạm
Xem chi tiết
Nguyễn Lê Phước Thịnh
20 tháng 12 2021 lúc 8:06

#include <bits/stdc++.h>

using namespace std;

long long n,i,a[10000];

int main()

{

cin>>n;

for (i=1; i<=n; i++)

cin>>a[i];

for (i=1; i<=n; i++) cout<<a[i]<<" ";

return 0;

}

Bình luận (0)
bui pham phuong Uyen
Xem chi tiết
Nguyễn Lê Phước Thịnh
27 tháng 1 2021 lúc 13:15

Bài 1: 

uses crt;

var a:array[1..100]of integer;

i,n,kt,max,x,j,tam:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do 

  begin

write('A[',i,']='); readln(a[i]);

end;

writeln('Mang ban vua nhap la: ');

for i:=1 to n do 

  write(a[i]:4);

writeln;

for i:=1 to n-1 do 

  for j:=i+1 to n do 

if a[i]>a[j] then 

begin

tam:=a[i];

a[i]:=a[j];

a[j]:=tam;

end;

writeln('Day tang dan la: ');

for i:=1 to n do 

  write(a[i]:4);

writeln;

write('Nhap x='); readln(x);

max:=0;

kt:=0;

for i:=1 to n do 

  if (a[i] mod 2=0) and (a[i]<=x) then 

   begin

  if max<a[i] then max:=a[i];

kt:=1;

end;

if kt=0 then writeln('Trong day khong co so le')

else writeln('So chan lon nhat khong vuot qua ',x,' la: ',max);

readln;

end.

Bình luận (0)
Thu Hiền
Xem chi tiết
Bao112233
17 tháng 12 2022 lúc 21:34

var n,i,dem,t:integer;
a:array[1..50] of integer;
begin
    dem:=0;
    t:=0;
    read(n);
    for i:=1 to n do 
    read(a[i]);
    for i:=n downto 1 do
    write(a[i]);
    writeln;
    for i:=1 to n do 
    if (a[i] mod 2 = 0) then dem:=dem+1;
    if a[i]<a[i-1] then t:=t+1;
    writeln(dem);
    if t=0 then write('Co lap thanh cap so +')
    else write('Ko the lap thanh cap so +');
    readln;
end.

Bình luận (0)
Tiến Đạt Huỳnh
Xem chi tiết
Thanh Phong (9A5)
27 tháng 4 2023 lúc 10:19

Uses crt;

var i,n: longint;

a: array[1..103] of longint;

begin clrscr;

readln(n);

for i:=1 to n do read(a[i]); readln;

for i:=1 to n do if(a[i] mod 2=0) then write(a[i],'  ');

for i:=1 to n do if(a[i] mod 2<>0) then write(a[i],'  ');

readln;

end.

Bình luận (2)
Nguyễn Hồng Anh
Xem chi tiết
Nguyễn Hồng Anh
Xem chi tiết
duyy
Xem chi tiết
Edward Paros
18 tháng 4 2023 lúc 22:31

program Tinh_Tong_Phan_Tu_Chan;

var
  A: array of Integer;
  N, i, sum: Integer;

begin
  Write('Nhap N: ');
  Readln(N);

  SetLength(A, N);

  // Nhập các phần tử cho mảng A
  for i := 0 to N - 1 do
  begin
    Write('Nhap phan tu thu ', i + 1, ': ');
    Readln(A[i]);
  end;

  // In lên màn hình các phần tử của mảng A
  Write('Cac phan tu cua mang la: ');
  for i := 0 to N - 1 do
  begin
    Write(A[i], ' ');
  end;
  Writeln;

  // Tính tổng các phần tử chẵn của mảng A và thông báo kết quả ra màn hình
  sum := 0;
  for i := 0 to N - 1 do
  begin
    if A[i] mod 2 = 0 then
      sum := sum + A[i];
  end;
  Writeln('Tong cac phan tu chan cua mang la: ', sum);

  Readln;
end.

Bình luận (0)
Phụng Lã
Xem chi tiết
Nguyễn Lê Phước Thịnh
16 tháng 12 2022 lúc 14:42

#include <bits/stdc++.h>

using namespace std;

int A[500],n,i,dem,dem1;

int main()

{

cin>>n;

for (int i=1; i<=n; i++) cin>>A[i];

for (int i=n; i>=1; i--) cout<<A[i]<<" ";

cout<<endl;

dem=0;

for (int i=1; i<=n; i++)

if (A[i]<10) dem++;

cout<<dem<<endl;

dem1=0;

for (int i=1; i<=n; i++)

if (A[i]>1)

{

bool kt=true;

for (int j=2; j*j<=A[i]; j++)

if (A[i]%j==0) kt=false;

if (kt==true) dem1++;

}

cout<<dem1;

return 0;

}

Bình luận (0)