Viết chương trình tìm tất cả các số nguyên x(0<x<100) sao cho \(x^2-30x+125=0\)
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.
program Tim_Uoc;
uses crt;
var
n, i: integer;
begin
clrscr;
write('Nhap vao mot so nguyen duong n: ');
readln(n);
writeln('Cac uoc cua so ', n, ' la: ');
for i:=1 to n do
begin
if n mod i = 0 then
writeln(i);
end;
readln;
end.
uses crt;
var i,n:longint;
function NT(a:longint):boolean;
var dem,j:longint;
begin
dem:=0;
for j:=1 to a do if(a mod j=0)then inc(dem);
NT:=dem=2;
end;
begin
clrscr;
write('nhap n:');readln(n);
for i:=1 to n do if(NT(i))then write(i,' ');
readln
end.
#include <bits/stdc++.h>
using namespace std;
long long k,i;
int main()
{
cin>>k;
for (i=1; i<=k; i++) if (k%i==0) cout<<i<<" ";
return 0;
}
Ai giải giúp mik đi ạ đag hok thj bị cô gọi lên bảng ko bt lm như thek nào mn giúp mik vs ạ 😭😭😭😭
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,i;
cin>>n;
for (i=1; i<=n; i++)
if (n%i==0) cout<<i<<" ";
return 0;
}
2:
#include <bits/stdc++.h>
using namespace std;
long long n,i;
int main()
{
cin>>n;
for (i=1; i<=n; i++)
if (n%i==0) cout<<i<<" ";
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int diaphuong(int n) {
if (n<2) {
return 0;
}
int squareRoot = (int) sqrt(n);
int i;
for(int i=2; i<=squareRoot; i++) {
if(n%i==0) {
return 0;
}
}
return 1;
}
int main() {
int i, N;
cin >> N;
for(int i=0; i<=N; i++) {
if(diaphuong(i)) {
cout << i << endl;
}
}
}
Chúc bn học tốt!
Bài 3:
uses crt;
var i:integer;
{------------------chuong-trinh-con-kiem-tra-so-nguyen-to----------------------}
function ktnt(x:integer):boolean;
var kt:boolean;
i:integer;
begin
kt:=true;
for i:=2 to x-1 do
if x mod i=0 then kt:=false;
if kt=true then ktnt:=true
else ktnt:=false;
end;
{-------------------------chuong-trinh-chinh----------------------------}
begin
clrscr;
for i:=2 to 9999 do
if (ktnt(i)=true) and (ktnt(i+2)=true) then
begin
writeln(i,',',i+2);
delay(500);
end;
readln;
end.
Bài 4:
uses crt;
var a,b,c,kt:integer;
begin
clrscr;
write('Nhap ngay:'); readln(a);
write('Nhap thang:'); readln(b);
write('Nhap nam:'); readln(c);
kt:=0;
if (b=1) and (0<a) and (a<=31) then kt:=1;
if (b=2) and (0<a) and (a<=28) then kt:=1;
if (b=2) and (0<a) and (a<=29) and (c mod 4=0) then kt:=1;
if (b=3) and (0<a) and (a<=31) then kt:=1;
if (b=4) and (0<a) and (a<=30) then kt:=1;
if (b=5) and (0<a) and (a<=31) then kt:=1;
if (b=6) and (0<a) and (a<=30) then kt:=1;
if (b=7) and (0<a) and (a<=31) then kt:=1;
if (b=8) and (0<a) and (a<=31) then kt:=1;
if (b=9) and (0<a) and (a<=30) then kt:=1;
if (b=10) and (0<a) and (a<=31) then kt:=1;
if (b=11) and (0<a) and (a<=30) then kt:=1;
if (b=12) and (0<a) and (a<=31) then kt:=1;
if kt=0 then writeln('Khong hop le')
else writeln('Hop le');
readln;
end.
==" cái này thì lập để giải pt baacjh ai thui mạng nhìu lắm