Những câu hỏi liên quan
Nguyễn Quang Tuấn
Xem chi tiết
Nguyễn Lê Phước Thịnh
12 tháng 5 2022 lúc 20:15

uses crt;

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

i,n,t:integer;

begin

clrscr;

readln(n);

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

for i:=1 to n do write(a[i]:4);

writeln;

t:=0;

for i:=1 to n do 

  if a[i] mod 2=0 then t:=t+a[i];

writeln(t);

readln;

end.

Bình luận (0)
Phan Ngoc
Xem chi tiết
zero
8 tháng 5 2022 lúc 14:54

refer

uses crt;

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

n,i,max,min:integer;

begin

clrscr;

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

for i:=1 to n do

begin

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

end;

max:=a[1];

min:=a[1];

for i:=1 to n do

begin

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

if min>a[i] then min:=a[i];

end;

writeln('Vi tri cua so lon nhat la: ');

for i:=1 to n do

if max=a[i] then write(i:4);

writeln;

writeln('Vi tri cua so nho nhat la: ');

for i:=1 to n do

if min=a[i] then write(i:4);

 

readln;

Bình luận (0)
Mỹ Phượng
Xem chi tiết
Nguyễn Lê Phước Thịnh
5 tháng 1 2022 lúc 11:29

#include <bits/stdc++.h>

using namespace std;

long long a[10],i,t,dem;

int main()

{

for (i=1; i<=10; i++) cin>>a[i];

t=0;

dem=0;

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

{

if (a[i]%2==0) t=t+a[i];

else dem++;

}

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

cout<<endl;

cout<<t<<endl;

cout<<dem;

return 0;

}

Bình luận (1)
Boa Hancock
Xem chi tiết
Nguyễn Lê Phước Thịnh
12 tháng 1 2022 lúc 22:33

#include <bits/stdc++.h>

using namespace std;

long long a[10],i,n,t1,dem1,s;

int main()

{

cin>>n;

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

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

cout<<endl;

t1=0;

dem1=0;

s=1;

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

{

if (a[i]%2==0) t1+=a[i];

else dem1+=1;

if ((a[i]%2==0) or (a[i]%3==0)) s=s*a[i];

}

cout<<t1<<endl;

cout<<dem1<<endl;

cout<<s;

return 0;

}

 

Bình luận (0)
Ly Trúc
Xem chi tiết
Ngô Bá Hùng
25 tháng 4 2023 lúc 23:31

program TimSoLonNhatVaDemSoAm;
var
  N, i, max, dem: integer;
  a: array[1..100] of integer;
begin
  writeln('Nhap so ptu cua day: ');
  readln(N);
  for i := 1 to N do
  begin
    write('Nhap ptu thu ', i, ': ');
    readln(a[i]);
  end;
  max := a[1];
  for i := 2 to N do
  begin
    if a[i] > max then
      max := a[i];
  end;
  writeln('So lon nhat trong day la: ', max);
  dem := 0;
  for i := 1 to N do
  begin
    if a[i] < 0 then
      dem := dem + 1;
  end;
  writeln('So ptu am trong day la: ', dem);
end.

Bình luận (0)
Boa Hancock
Xem chi tiết
Boa Hancock
12 tháng 1 2022 lúc 7:58

Viết câu lệnh thực hiện yêu cầu sau:

4. Với dữ liệu câu 2, yêu cầu tính và in ra màn hình:

4a. Tổng các số chẵn

4b. Đếm các số lẽ

4c. Tích các số chia hết cho 2 hoặc 3

 

Bình luận (0)
Nguyễn Lê Phước Thịnh
12 tháng 1 2022 lúc 22:33

#include <bits/stdc++.h>

using namespace std;

long long a[10],i,n,t1,dem1,s;

int main()

{

cin>>n;

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

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

cout<<endl;

t1=0;

dem1=0;

s=1;

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

{

if (a[i]%2==0) t1+=a[i];

else dem1+=1;

if ((a[i]%2==0) or (a[i]%3==0)) s=s*a[i];

}

cout<<t1<<endl;

cout<<dem1<<endl;

cout<<s;

return 0;

}

 

Bình luận (0)
Thảo
Xem chi tiết
Nguyễn Lê Phước Thịnh
14 tháng 12 2020 lúc 22:20

uses crt;

var g:array[1..5]of integer;

i,vtc,vtl:integer;

begin

clrscr;

for i:=1 to 5 do 

  begin

write('G[',i,']='); readln(g[i]);

end;

vtc:=0;

vtl:=0;

for i:=1 to 5 do 

  begin

if g[i] mod 2=0 then 

  begin

  if vtc<i then vtc:=i;

end

else begin

if vtl<i then vtl:=i;

end;

end;

writeln('Vi tri phan tu le cuoi cung la: ',vtl);

writeln('Vi tri phan tu chan cuoi cung la: ',vtc);

readln;

end. 

Bình luận (0)
Thanh Nhi Phạm
Xem chi tiết
Nguyễn Lê Phước Thịnh
23 tháng 4 2021 lúc 20:12

Mình chỉ viết chương trình chính thôi, còn chương trình con bạn tự viết nhé

uses crt;

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

i,n,t,t1,t2:integer;

begin

clrscr;

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

for i:=1 to n do 

 begin

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

edn;

t:=0;

for i:=1 to n do 

 t:=t+a[i];

writeln(t);

readln;

end.

Bình luận (0)
dinhnguyentuhuy
Xem chi tiết
Nguyễn Lê Phước Thịnh
13 tháng 12 2020 lúc 17:15

uses crt;

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

i,n,t,kt,j:integer;

begin

clrscr;

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

for i:=1 to n do

begin

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

end;

writeln('Cac so vua nhap la: ');

for i:=1 to n do 

  write(a[i]:4);

writeln;

t:=0;

for i:=1 to n do 

  t:=t+a[i];

writeln('Tong cua day so la: ',t);

kt:=0;

for j:=2 to trunc(sqrt(t)) do 

  if t mod j=0 then 

    begin

kt:=1;

break;

end;

if kt=0 then writeln(t,' la so nguyen to')

else writeln(t,' khong la so nguyen to');

readln;

end.

Bình luận (1)