Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.
Bài 1:
program in_phan_tu;
uses crt;
var n,i:longint;
a:array[1..100] of longint;
begin
clrscr;
write('nhap so n:');readln(n);
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
for i:=1 to n do
write(a[i]:3);
readln;
end.
Bài 2:
program tong_phan_tu;
uses crt;
var n,i,tong:longint;
a:array[1..100] of longint;
begin
clrscr;
write('nhap so n:');readln(n);
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
tong:=0;
for i:=1 to n do
tong:=tong+a[i];
writeln('tong cua day la:');
readln;
end.
Bài 3:
program tong_phan_tu_chan;
uses crt;
var n,i,tong:longint;
a:array[1..100] of longint;
begin
clrscr;
write('nhap so n:');readln(n);
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
tong:=0;
for i:=1 to n do
if a[i] mod 2=0 then tong:=tong+a[i];
writeln('tong cua day la:');
readln;
end.
Câu 1:
uses crt;
var a:array[1..100]of integer;
i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n do
write(a[i]:4);
readln;
end.
Bài 1:
#include <bits/stdc++.h>
using namespace std;
long long n,i;
bool kt;
int main()
{
cin>>n;
if (n>1)
{
kt=true;
for (i=2; i*i<=n; i++)
if (n%i==0) kt=false;
if (kt==true) cout<<n<<" la so nguyen to";
else cout<<n<<" khong la so nguyen to";
}
else cout<<n<<" khong la so nguyen to";
return 0;
}
Bài 1:
Program HOC24;
var a: array[1..1000] of integer;
i,n,d: integer;
begin
write('Nhap so phan tu: '); readln(n);
for i:=1 to n do
begin
write('Nhap so thu ',i,': '); readln(a[i]);
end;
for i:=1 to n do if (a[i]<0) and (a[i] mod 2=0) then d:=d+1;
write('Co ',d,' so nguyen am chan trong day so');
readln
end.
Bài 2:
Program HOC24;
var a: array[1..1000] of integer;
i,n: integer;
t: longint;
begin
write('Nhap so phan tu: '); readln(n);
for i:=1 to n do
begin
write('Nhap so thu ',i,': '); readln(a[i]);
end;
t:=0;
for i:=1 to n do if a[i] mod 5=0 then t:=t+a[i];
write(Tong la: ',t);
readln
end.
Câu 2:
#include <bits/stdc++.h>
using namespace std;
long long n;
int main()
{
cin>>n;
if (n>0 && n%5==0) cout<<"Phai";
else cout<<"Khong phai";
}
var x, i : integer;
begin
writeln('nhap so nguyen x : ')
read(x);
if ( x < 2) then writeln(' x khong phai so nguyen to');
else if ( x > 2) then
begin
for i := 2 to ( x - 1) do
begin
if ( x mod i = 0) then writeln(' x khong la so nguyen to');
end;
end;
else
writeln(' x la so nguyen to');
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long n;
//chuongtrinhcon
bool ktnt(long long n)
{
if (n<2) return(false);
else
for (int i=2; i*i<=n;i++)
if (n%i==0) return (false);
return(true);
}
//chuongtrinhchinh
int main()
{
//freopen("KTSNT.INP","r",stdin);
//freopen("KTSNT.OUT","w",stdout);
cin>>n;
if (ktnt(n)==true) cout<<"1";
else cout<<"0";
return 0;
}
Cau 1:
Câu 2:
#include <bits/stdc++.h>
using namespace std;
long long n;
int main()
{
cin>>n;
if (n>0 && n%5==0) cout<<"Phai";
else cout<<"Khong phai";
}
1 không
2
Program UCLN;
uses crt;
var a,b : integer;
begin
write ('nhap so a la ');readln (a);
write ('nhap so b la ');readln (b);
while a < > b do
if a >b then a := a - b else b := b - a ;
write ( ' UCLN la :' , a );
readln
end.
1:
#include <bits/stdc++.h>
using namespace std;
int n,i;
bool kt;
int main()
{
cin>>n;
kt=true;
for (i=2; i*i<=n; i++)
if (n%i==0) kt=false;
if (kt==true && n>1) cout<<"La so nguyen to";
else cout<<"Khong la so nguyen to";
return 0;
}