Những câu hỏi liên quan
phamthiminhanh
Xem chi tiết
nguyễn an phát
23 tháng 3 2021 lúc 14:39

bài 1:

program tinhtong;

uses crt;

var n,s,i:longint;

begin

clrscr;

repeat

write('nhap so n:');readln(n);

until (n>=10)and(n<100);

s:=0;

for i:=10 to n do

if (i mod 2)=0 then s:=s+i;

write('tong cua cac so co hang don vi chan la:',s);

readln;

end.

bài 2:

program kiem_tra_so_nguyen_to;

uses crt;

var n,j,i:longint;

begin

clrscr;

write('nhap so n:');readln(n);

j:=0;

for i:=1 to n do

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

if j=2 then write(n,'la so nguyen to')

else write(n,'khong phai la so nguyen to');

readln;

end.

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

Cách khác:

Bài 2: 

uses crt;

var n,i,kt:integer;

begin

clrscr;

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

if n>1 then 

begin

kt:=0;

for i:=2 to n-1 do 

  if n mod i=0 then kt:=1;

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

else writeln(n,' la hop so');

end

else writeln(n,' khong la so nguyen to cung khong la hop so');

readln;

end.

Bình luận (0)
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)
Đỗ Thiên
Xem chi tiết
Nguyễn Lê Phước Thịnh
21 tháng 10 2021 lúc 23:45

#include <bits/stdc++.h>

using namespace std;

int i,n;

int main()

{

cin>>n;

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

cout<<"* ";

return 0;

}

Bình luận (0)
Yến Nhi Phan
Xem chi tiết
Minh Lệ
22 tháng 3 2023 lúc 13:18

Program HOC24;

var d,i,n: integer;

begin

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

d:=0;

for i:=1 to n do if i mod 2=0 then d:=d+1;

write('Co ',d,' so chan');

readln

end.

Bình luận (0)
Selena
Xem chi tiết
datcoder
3 tháng 2 lúc 13:52

#include <bits/stdc++.h>

using namespace std;

int main(){

    int n;

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

         cout << n <<" x " << i <<" = "<<n*i;

    return 0;

}

Bình luận (0)
lê anh tuấn
Xem chi tiết
Lee Jihoon
Xem chi tiết
Nguyễn Lê Phước Thịnh
23 tháng 2 2021 lúc 21:47

uses crt;

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

i,n,k,t:integer;

begin

clrscr;

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

for i:=1 to n do

begin

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

end;

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

t:=0;

for i:=1 to n do 

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

writeln('Tong cac so la boi cua ',k,' la: ',t);

readln;

end.

Bình luận (1)
Bùi Ngọc Khánh Huyền
Xem chi tiết
Nguyễn Lê Phước Thịnh
6 tháng 8 2023 lúc 19:54

uses crt;

var i,n,m,j,kt:integer;

begin

clrscr;

readln(n,m);

for i:=n to m do

begin

kt:=0;

if (i>2) then begin

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

if i mod j=0 then kt:=1;

if kt=0 then write(i:4);

end;

readln;

end.

Bình luận (0)
Hiếu
Xem chi tiết