Những câu hỏi liên quan
Sơn Trần
Xem chi tiết
Nguyễn Văn Tú
Xem chi tiết
Quân Nguyễn
Xem chi tiết
Nguyễn Lê Phước Thịnh
23 tháng 12 2020 lúc 20:57

Câu 1: 

uses crt;

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

i,n,t:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

  end;

t:=0;

for i:=1 to n do 

  if (a[i]<0) and (a[i] mod 7=0) then t:=t+a[i];

writeln('Tong cac so am chia het cho 7 la: ',t);

readln;

end.

Câu 2: 

uses crt;

var c,a:array[1..10]of integer;

i,kt,j,dem:integer;

begin

clrscr;

for i:=1 to 10 do 

  begin

write('C[',i,']='); readln(c[i]);

end;

dem:=0;

for i:=1 to 10 do 

  if c[i]>1 then 

begin

kt:=0;

for j:=2 to c[i]-1 do 

  if c[i] mod j=0 then kt:=1;

if kt=0 then 

begin

inc(dem);

a[dem]:=c[i];

end;

end;

if dem=0 then writeln('Trong day khong co so nguyen to')

else begin

writeln('Cac so nguyen to trong day la: ');

for i:=1 to dem do

write(a[i]:4);

end;

readln;

end.

Câu 3: 

uses crt;

var d:array[1..200]of integer;

i,k,dem:integer;

begin

clrscr;

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

for i:=1 to k do 

  begin

write('D[',i,']='); readln(d[i]);

end;

dem:=0;

for i:=1 to k do 

  if (a[i] mod 2=0) and (a[i]>=10) then inc(dem);

writeln('So phan tu chan co 2 chu so la: ',dem);

readln;

end.

Bình luận (0)
Trần Gia Bảo
Xem chi tiết
Nguyễn Lê Phước Thịnh
5 tháng 4 2022 lúc 7:28

#include <bits/stdc++.h>

using namespace std;

long long a[1000],i,n,t,dem,s;

int main()

{

cin>>n;

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

t=0;

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

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

cout<<t<<endl;

dem=0;

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

if (a[i]%5==2) dem++;

cout<<dem<<endl;

s=1;

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

if (a[i]%7==3) s*=a[i];

cout<<s;

return 0;

}

Bình luận (0)
Đỗ trung học
Xem chi tiết
Khavid Ngô
15 tháng 3 2021 lúc 20:51

Bình luận (0)
Nguyễn Lê Phước Thịnh
15 tháng 3 2021 lúc 20:52

const fi='dl.pas'

fo='qk.pas'

var f1,f2:text;

i,n,dem,t,dem1,dem2,kt,j:integer;

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

begin

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

readln(f1,n);

for i:=1 to n do 

  read(f1,a[i]);

dem:=0;

for i:=1 to n do 

  if (a[i] mod 2<>0) and (a[i] mod 7=0) then inc(dem);

t:=0;

for i:=1 to n do

  if (10<=a[i]) and (a[i]<=30) then t:=t+a[i];

dem1:=0;

for i:=1 to n do 

  if (a[i]<0) and (a[i] mod 2<>0) then inc(dem1);

dem2:=0;

for i:=1 to n do 

  if a[i]>1 then

begin

kt:=0;

for j:=2 to a[i]-1 do 

  if a[i] mod j=0 then kt:=1;

if kt=0 then inc(dem2);

end;

writeln(f2,'So phan tu le chia het cho 7 la: ',dem);

writeln(f2,'Tong cac phan tu thuoc [10,30] la: ',t);

writeln(f2,'So cac phan tu am le la: ',dem1);

writeln(f2,'So phan tu la so nguyen to la: ',dem2);

close(f1);

close(f2);

end.

Bình luận (0)
Vochehoang
Xem chi tiết
Nguyễn Lê Phước Thịnh
26 tháng 4 2021 lúc 20:04

Câu 1: 

uses crt;

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

i,n:integer;

t:real;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

t:=0;

for i:=1 to n do 

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

writeln(t:4:2);

readln;

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
26 tháng 4 2021 lúc 20:05

Câu 2: 

uses crt;

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

i,n:integer;

t:real;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

t:=1;

for i:=1 to n do 

  t:=t*a[i];

writeln(t:4:2);

readln;

end.

Bình luận (0)
nguyễn hoàng long
Xem chi tiết
Nguyễn Lê Phước Thịnh
21 tháng 1 2022 lúc 22:00

#include <bits/stdc++.h>

using namespace std;

long long a[100],n,i,t,t1,dem,dem1;

//chuongtrinhcon

bool ktnt(long long x)

{

if (x<=1) return(false);

for (int i=2; i*i<=x; i++)

if (x%i==0) return(false);

return true;

}

//chuongtrinhchinh

int main()

{

cin>>n;

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

{

cin>>a[i];

}

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

cout<<endl;

t=0;

for (i=1; i<=n; i++) if (a[i]%2==0) t=t+a[i];

cout<<t<<endl;

dem=0;

for (i=1; i<=n; i++) if (a[i]%3==0) dem++;

cout<<dem<<" ";

t1=0;

dem1=0;

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

if (a[i]%2!=0)

{

t1+=a[i];

dem1++;

}

cout<<fixed<<setprecision(2)<<(t1*1.0)/(dem1*1.0)<<endl;

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

if (ktnt(a[i])==true) cout<<a[i]<<" ";

return 0;

}

Bình luận (0)
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)
Thu hằng
Xem chi tiết
Nguyễn Lê Phước Thịnh
11 tháng 11 2021 lúc 23:40

#include <bits/stdc++.h>

using namespace std;

long long n,i,x;

int main()

{

cin>>n;

long long t=0;

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

{

cin>>x;

if (x%3==0) t=t+x;

}

cout<<t;

return 0;

}

Bình luận (0)