Những câu hỏi liên quan
Đỗ 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)
Lala
Xem chi tiết
Trương Huy Hoàng
13 tháng 12 2023 lúc 22:58

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll> mp;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    freopen("MAP1.INP","r",stdin);
    freopen("MAP1.OUT","w",stdout);
    ll n; cin >> n;
    ll a[n+5];
    for(ll i=1;i<=n;i++) cin >> a[i], mp[a[i]]++;
    for(pair<ll,ll> it:mp) cout << it.first << " " << it.second << "\n";
}

Chúc bạn học tốt!

Bình luận (0)
Trâm Đỗ
Xem chi tiết
Nguyễn Lê Phước Thịnh
7 tháng 12 2021 lúc 23:07

1:

#include <bits/stdc++.h>

using namespace std;

long long t1,t2,i,n,x;

int main()

{

cin>>n;

t1=0;

t2=0;

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

{

cin>>x;

if (x>0) t1=t1+x;

else t2=t2+x;

}

cout<<t1<<" "<<t2;

return 0;

}

Bình luận (0)
Anh Thư
Xem chi tiết
Minh Lệ
10 tháng 4 2021 lúc 18:25

Program HOC24;

var d,i,n: integer;

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

t: longint;

function nt(x: longint): boolean;

var j: longint;

begin

nt:=true;

if (x=2) or (x=3) then exit;

nt:=false;

if (x=1) or (x mod 2=0) or (x mod 3=0) then exit;

j:=5;

while j<=trunc(sqrt(x)) do

begin

if (x mod j=0) or (x mod (j+2)=0) then exit;

j:=j+6;

end;

nt:=true;

end;

begin

write('Nhap N: '); readln(n);

for i:=1 to n do

begin

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

end;

d:=0; t:=0;

for i:=1 to n do

if nt(a[i]) then

begin

d:=d+1;

t:=t+a[i];

end;

writeln('Co ',d,' so nguyen to trong day');

write('Tong cac so nguyen to trong day la: ',t);

readln

end.

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

uses crt;

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

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

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

dem:=0;

t:=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

begin

inc(dem);

t:=t+a[i];

end;

end;

writeln('So luong so nguyen to la: ',dem);

writeln('Tong cac so nguyen to la: ',t);

readln;

end.

Bình luận (0)
Bé Thúy
Xem chi tiết
Nguyễn Lê Phước Thịnh
13 tháng 4 2021 lúc 21:23

uses crt;

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

i,dem,t:integer;

begin

clrscr;

for i:=1 to 6 do 

  begin

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

end;

dem:=0;

t:=0;

for i:=1 to 6 do 

if a[i]>0 then 

begin

inc(dem);

t:=t+a[i];

end;

writeln('So phan tu duong la: ',dem);

writeln('Tong cac phan tu duong la: ',t);

readln;

end.

Bình luận (0)
Đặng Phạm Thành Nhật
Xem chi tiết
Đặng Phạm Thành Nhật
28 tháng 9 2021 lúc 16:27

mình ghi dư cái số 4 bên phần BAI7.INP nha mn

 

Bình luận (1)
Nguyễn Ngọc
Xem chi tiết
Lê Văn Thành
5 tháng 1 2023 lúc 14:59

uses crt;

var n,i,s,t,j,max:longint;a,b:array[1..100] of longint;tbc:real;

function snt(n:longint):boolean;

var j:longint;

begin

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

if n mod j=0 then exit(false);

exit(n>1);

end;

begin

readln(N);

for i:=1 to n do

begin

read (a[i]);

if snt(a[i])=true then 

begin

j:=j+1;

b[j]:=a[i];

end;

end;

t:=b[1];

max:=b[1];

for i:=2 to j do

begin

if b[i]>max then max:=b[i];

t:=t+b[i];

write(b[i]:4);

end;

tbc:=t/j;

writeln(S);

writeln(tbc);

writeln(max);

readln;

end.

 

 

 

Bình luận (0)
Minh Duy
Xem chi tiết
Bùi Anh Tuấn
27 tháng 4 2021 lúc 19:53

 tách ra từng câu hỏi đi bro

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

Câu 1: 

uses crt;

var a:array[1..200]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] mod 2=0 then t:=t+a[i];

writeln(t);

readln;

end.

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

2:

uses crt;

var a:array[1..200]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:=1;

for i:=1 to n do 

  t:=t*a[i];

writeln(t);

readln;

end.

Bình luận (0)
Vũ Ngọc Lan
Xem chi tiết