Những câu hỏi liên quan
Miner Đức
Xem chi tiết
Nguyễn Lê Phước Thịnh
14 tháng 3 2022 lúc 8:23

#include <bits/stdc++.h>

using namespace std;

long long n,i,x;

//chuongtrinhcon

bool ktnt(long long x)

{

if (x<2) return false;

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

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

return true;

}

//chuongtrinhchinh

int main()

{

freopen("dl.dat","r",stdin);

freopen("kq.dat","w",stdout);

cin>>n;

dem=0;

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

{

cin>>x;

if (ktnt(x)) dem++;

}

cout<<dem;

return 0;

}

Bình luận (0)
Miner Đức
Xem chi tiết
Dương Hữu Thành
Xem chi tiết
Quỳnh Như
Xem chi tiết
Nguyễn Lê Phước Thịnh
10 tháng 5 2022 lúc 23:21

uses crt;

const fi='songuyen.inp'

fo='songuyen2.out'

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

i,n,t1:integer;

f1,f2:text;

begin

clrscr;

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

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

readln(f1,n);

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

t1:=0;

for i:=1 to n do if a[i] mod 2<>0 then t1:=t1+a[i];

writeln(t1);

writeln(f2,t1);

for i:=1 to n do 

  if a[i] mod 2<>0 then write(a[i]:4);

close(f1);

close(f2);

readln;

end.

Bình luận (0)
Quỳnh Anh
Xem chi tiết
Nguyễn Lê Phước Thịnh
8 tháng 5 2021 lúc 20:33

const fi='bai1.inp'

fo='bai1.out'

var f1,f2:text;

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

n,i,t,dem: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]);

t:=0;

dem:=0;

for i:=1 to n do 

  begin

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

else inc(dem);

end;

writeln(f2,'Tong cac so le la: ',t);

writeln(f2,'So so chan la: ',dem);

close(f1);

close(f2);

end.

Bình luận (0)
Mĩ Lâm
Xem chi tiết
Nguyên Hưng Trần
22 tháng 7 2021 lúc 21:25

Uses crt;
var f1,f2:text;
    i,n,tong,tongchan,dem:integer;
    tb:real;
Begin
 clrscr;
 Assign(f1,'DAYSO.txt');
 Assign(f2,'KETQUA.txt');
 reset(f1);dem:=0;tong:=0;tongchan:=0;
 While Not EOF(f1) do
  Begin
  read(f1,i);
  inc(tong,i);
  If i mod 2 = 0 then
    begin
    inc(dem);
    inc(tongchan,i);
    end;
  End;
 tb:=tongchan/dem;
 close(f1);
 rewrite(f2);
 writeln(f2,tong);
 writeln(f2,tongchan);
 writeln(f2,tb:0:2);
 close(f2);
 write(tong);
 readln;
End.

Bình luận (0)
Miner Đức
Xem chi tiết
Nguyễn Lê Phước Thịnh
12 tháng 5 2022 lúc 9:11

#include <bits/stdc++.h>

using namespace std;

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

int main()

{

freopen("dl.inp","r",stdin);

freopen("dl.dat","w",stdout);

cin>>n;

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

dem=0;

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

if (a[i]==10) dem++;

cout<<dem;

return 0;

}

Bình luận (0)
Phan Tú
Xem chi tiết
Linh
Xem chi tiết
Nguyễn Lê Phước Thịnh
8 tháng 3 2022 lúc 23:00

#include <bits/stdc++.h>

using namespace std;

long long n,i,t;

int main()

{

freopen("dulieu.txt","r",stdin);

freopen("uot.txt","w",stdout);

cin>>n;

t=0;

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

if (i%2==0) t+=i;

cout<<t;

return 0;

}

Bình luận (0)