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

Bài 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 5=0 then t:=t+a[i];

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

readln;

end.

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

Bài 2: 

uses crt;

var st:string;

d,i:integer;

begin

clrscr;

write('Nhap xau:'); readln(st);

d:=length(st);

for i:=1 to d do 

  if st[i]=#32 then delete(st,i,1);

writeln(st);

readln;

end.

Bình luận (0)
scar titan
28 tháng 7 2021 lúc 10:11

python có ko bạn

 

Bình luận (0)
trần hoàng
Xem chi tiết
Nguyễn Lê Phước Thịnh
4 tháng 4 2022 lúc 21:53

#include <bits/stdc++.h>

using namespace std;

long long i,n,kt,j;

int main()

{

cin>>n;

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

{

kt=0;

for (j=2; j*j<=i; j++)

if (i%j==0) kt=1;

if (kt==0) cout<<i<<" ";

}

return 0;

}

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

uses crt;

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

i,n,tbc,dem: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 duong chan la: ');

for i:=1 to n do 

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

writeln;

tbc:=0;

dem:=0;

for i:=1 to n do 

  if (-1000<=a[i]) and (a[i]<=1000) then

begin

tbc:=tbc+a[i];

dem:=dem+1;

end;

writeln('Trung binh cong cac phan tu co gia tri trong pham vi tu -1000 den 1000 la: ',tbc/dem:4:2);

readln;

end.

Bình luận (0)
Lê Tâm Anh
Xem chi tiết
gấu béo
7 tháng 5 2023 lúc 19:20

program Le_Nho_Hon_Hoac_Bang_n;

uses crt;

var

       n, i: integer;

begin

       clrscr;

       write('Nhap vao mot so nguyen duong n: ');

       readln(n);

       while n <= 0 do

       begin

              writeln('So ban nhap khong hop le. Xin vui long nhap lai: ');

              readln(n);

       end;

       clrscr;

       writeln('Cac so le nho hon hoac bang ', n, ' la:');

       i := 1;

       while i <= n do

       begin

              if i mod 2 <> 0 then

                     writeln(i);

              i := i + 1;

       end;

       readln;

end.

Bình luận (0)
Gà Công Nghệ
Xem chi tiết
Anh Phạm
28 tháng 8 2021 lúc 19:43

uses crt;

var n,i,o,d:integer;

function ktnt(n:integer): integer;

var i,d:integer;

begin

d:=0;

for i:=1 to sqrt(n) do

if (n mod i=0) then d:=d+1;

if d=2 then ktnt=0

else ktnt=1;

end;

begin

readln(n);

writeln(' so nguyen to be hon hoac bang n la'); {a}

for i:=1 to n do

if ktnt(i)=0 then writeln(i);

writeln('so nguyen to nho nhat khong be hon n');

o:=n;

while o>0 do

begin

if ktnt(o)=0 then

begin

write(o);

break;

end;

o:=o+1;

end;

writeln('cặp số nguyên tố là hai số nguyên lẻ liên tiếp nhỏ hơn hoặc bằng n');

o:=0;

o:=1;

d:=0;

for i:=o+2 to n do

begin

if ktnt(i)=0 then

begin

d:=d+1;

write(i,' ');

if d<2 then continue;

end;

d:=0;

writeln;

end;

readln;

end.

Bình luận (1)
Bùi Thị Châu Loan
Xem chi tiết
Nguyễn Lê Phước Thịnh
8 tháng 3 2021 lúc 13:55

uses crt;

var n,i:integer;

m:real;

begin

clrscr;

repeat

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

until (1<=n) and (n<=30000);

m:=0;

for i:=1 to n do 

  m:=m+sqrt(i);

writeln('m=',m:4:2);

readln;

end.

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

uses crt;

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

i,n,tc,tl,t:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

tc:=0;

tl:=0;

for i:=1 to n do 

  begin

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

else tl:=tl+a[i];

end;

writeln('Tong cac so chan la: ',tc);

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

t:=0;

for i:=1 to n do  

t:=t+a[i];

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

readln;

end. 

Bình luận (1)
Ngọc hà
Xem chi tiết
Nhung
23 tháng 5 2022 lúc 22:38

program trungbinh;

uses crt;

var n,i: integer;

      s:real;

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

begin

clrscr;

write('Nhap do dai day: '); readln(n);

writeln('Nhap gia tri cua day: ');

S:=0;

for i:=1 to n do

begin

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

readln(A[i]);

S:=S+A[i];

end;

S:=S/n;

write('Trung binh cua cac so cua day do la: ',S);

readln;

end.

Bình luận (0)
Nguyễn Thái Luật
Xem chi tiết
datcoder
26 tháng 3 lúc 8:34

#include <stdio.h>

int main(){

    int n;

    scanf("%d",&n);

    long t=0; int i,j;

    for (i=2; i<=n; i++){

        int c=0;

        for (j=2; j<i; j++)

            if (i%j==0) c++;

        if (c==0) t=t+i;

        }

printf("%d",t);

return 0;

}

Bình luận (0)
datcoder
9 tháng 1 lúc 23:47

Bạn trình bày lại đề bài rõ hơn nha, đề đọc rất khó hiểu ấy.

Bình luận (2)
nguyen thi be
Xem chi tiết
Nguyễn Lê Phước Thịnh
29 tháng 12 2020 lúc 11:58

uses crt;

var n,i,t:integer;

begin

clrscr;

repeat

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

until n>0;

t:=0;

for i:=1 to n do 

  if i mod 3=0 then t:=t+i;

writeln('Tong cac so chia het cho 3 trong khoang tu 1 toi ',n,' la: ',t);

readln;

end.

Bình luận (0)