viet chuong trinh kiem tra 1so nguyen nco hai la so nguyen to hay ko
chuong trinh yeu cau nguoi nhap vao 1 so nho hon 100 neu nguoi dung nhap vao 1 so lon hon 100 thi yeu cau nguoi nhap lai sau do kiem tra so nhap vao co phai la so nguyen to ko
uses crt;
var n,i:integer;
kt:boolean;
begin
clrscr;
repeat
readln(n);
until n<=100;
if (n<2) then writeln('khong la so nguyen to')
else begin
kt:=true;
for i:=2 to trunc(sqrt(n)) do
if n mod i=0 then kt:=false;
if kt=true then write('la so nguyen to')
else write('khong la so nguyen to');
end;
readln;
end.
viet chuong trinh nhap so n va xuat ra so vua nhap(n la so nguyen)
Uses crt;
var n:integer;
Begin
clrscr;
Writeln('Nhap so n= '); Readln(n);
Write('So vua nhap la ',n);
Readln
End.
viet chuong trinh nhap vao so mguyen n va day so gom n la so nguyen tu ban phim in ra man hinh so lon nhat trong day so nguyen vua nhap
Lời giải :
program hotrotinhoc ;
var a: array[1..32000] of integer ;
i,n,max : integer ;
begin
write('Nhap n='); readln(n);
writeln('Nhap gia tri cua cac phan tu');
for i:= 1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
max:=a[1];
for i:= 1 to n do if max<a[i] then max:=a[i];
write('So lon nhat la:',max');
readln
end.
Viet chuong trinh nhap vao cac so nguyen a,b,c,d,e tinh tong cac so co chu so tan cung la 5 va 0
#include <bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,t;
int main()
{
cin>>a>>b>>c>>d>>e;
t=0;
if ((a%10==0) or (a%10==5)) t=t+a;
if ((b%10==0) or (b%10==5)) t=t+b;
if ((c%10==0) or (c%10==5)) t=t+c;
if ((d%10==0) or (d%10==5)) t=t+d;
if ((e%10==0) or (e%10==5)) t=t+e;
cout<<t;
return 0;
}
viet chuong trinh nhap vao mot day so nguyen dua ra man hinh tong so nguyen am trong day so
#include <bits/stdc++.h>
using namespace std;
long long t,i,n,x;
int main()
{
cin>>n;
t=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x<0) t=t+x;
}
cout<<t;
return 0;
}
1so nguyen to chia cho 30 co so du la r tỉm r biet r ko phai la so nguyen to
trinh viet chuong nhap vao 1 mang 1 chieu gom n phan tu ( voi n duoc nhap vao tu ban phim ). Hay thuc hien cac cong viec sau:
-Nhap/xuar mang
- Dem co bao nhieu phan tu la so chan trong mang
-Kiem tra xem mang co phai la mang le hay khong ? ( tat ca cac phan tu mang la so le )
Bạn ơi phải viết bằng ngôn ngữ lập trình gì vậy.
viet chuong trinh con thuc hien nhap vao mang 1 chieu A gom N so nguyen . sau do thuc hienn ct con bo tham so tuong ung la (N=6 , cac phan tu mang lan luot la 2,4,6,3,5,7)
viet chuong trinh nhap vao so nguyen a va b . In ra man hinh ket qua a co chia het cho b hay khong moi nguoi giup em gap voi
#include <bits/stdc++.h>
using namespace std;
long long a,b;
int main()
{
cin>>a>>b;
if (a%b==0) cout<<"YES";
else cout<<"NO";
return 0;
}