nhập vào 2 số a,b đếm xem trong đoạn[a,b] có bao nhiêu số nguyên tố
viết c++ dùng bits/stdc++.h
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.
#include <iostream>
using namespace std;
int main() {
int num;
cout << "Nhap vao mot so nguyen co 2 chu so: ";
cin >> num;
int hang_chuc = num / 10;
int hang_don_vi = num % 10;
cout << "Chu so hang chuc: " << hang_chuc << endl;
cout << "Chu so hang don vi: " << hang_don_vi << endl;
return 0;
}
#include<iostream>
using namespace std;
int main() {
int n, tram, chuc, donvi;
cout<<"Nhap vao mot so co 3 chu so: ";
cin>>n;
tram = n / 100;
chuc = (n%100) / 10;
donvi = (n%100) % 10;
cout<<"Chu so hang tram cua so "<<n<<" la: "<<tram<<endl;
cout<<"Chu so hang chuc cua so "<<n<<" la: "<<chuc<<endl;
cout<<"Chu so hang don vi cua so "<<n<<" la: "<<donvi<<endl;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll a;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>a;
cout<<a/100<<"\n"<<(a/10)%10<<"\n"<<a%10;
}
out tu đúng
uses crt;
var st:string;
a:array[1..255]of string;
i,n,d,kt,j,dem,dem1,dem2:integer;
begin
clrscr;
readln(st);
d:=length(st);
dem:=1;
a[1]:=st[1];
for i:=1 to d do
begin
kt:=0;
for j:=1 to dem do
if a[j]=st[i] then kt:=1;
if kt=0 then
begin
dem:=dem+1;
a[dem]:=st[i];
end;
end;
dem1:=0;
dem2:=0;
for i:=1 to dem do
begin
if st[i] in ['A'..'Z'] then dem1:=dem1+1;
if st[i] in ['a'..'z'] then inc(dem1);
if st[i] in ['0'..'9'] then inc(dem2);
end;
writeln(dem1);
writeln(dem2);
readln;
end.
var a:array[1..1000] of integer;
i,n,d,max:integer;
begin
write('n = ');readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,' = ');readln(a[i]);
if a[i] mod 2 <> 0 then d:=d+1;
end;
max:=a[1];
for i:=2 to n do
if a[i] > max then max:=a[i];
writeln('Co ',d,' so le');
write('So lon nhat la ',max);
readln
end.
Var a:array[1..200] of integer;
i,n,dem:integer;
Begin
Write('Nhap so luong phan tu n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap phan tu thu ',i,' = ');readln(a[i]);
End;
dem:=0;
For i:=1 to n do
If a[i]>5 then dem:=dem+1;
Write('So phan tu lon hon 5 la ',dem);
Readln;
End.
program CapSoChinhPhuong;
uses crt;
var
n, a, b, count: integer;
begin
clrscr;
write('Nhap vao so nguyen n: ');
readln(n);
count := 0;
writeln('Cac cap so a, b sao cho a^2 + b^2 la so chinh phuong la:');
for a := 1 to n do begin
for b := 1 to n do begin
if (sqr(a) + sqr(b)) mod round(sqrt(sqr(a) + sqr(b))) = 0 then begin
writeln('a = ', a, ', b = ', b);
count := count + 1;
end;
end;
end;
writeln('Tong so cap so la: ', count);
readln;
end.
Program HOC24;
var d,i,n: integer;
a: array[1..1000] of integer;
t: longint;
function nt(x: longint): boolean;
var j: longint;
begin
nt:=true;
if (x=2) or (x=3) then exit;
nt:=false;
if (x=1) or (x mod 2=0) or (x mod 3=0) then exit;
j:=5;
while j<=trunc(sqrt(x)) do
begin
if (x mod j=0) or (x mod (j+2)=0) then exit;
j:=j+6;
end;
nt:=true;
end;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
d:=0; t:=0;
for i:=1 to n do
if nt(a[i]) then
begin
d:=d+1;
t:=t+a[i];
end;
writeln('Co ',d,' so nguyen to trong day');
write('Tong cac so nguyen to trong day la: ',t);
readln
end.
uses crt;
var a:array[1..1000]of integer;
i,n,dem,t,j,kt:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
t:=0;
for i:=1 to n do
if a[i]>1 then
begin
kt:=0;
for j:=2 to a[i]-1 do
if a[i] mod j=0 then kt:=1;
if kt=0 then
begin
inc(dem);
t:=t+a[i];
end;
end;
writeln('So luong so nguyen to la: ',dem);
writeln('Tong cac so nguyen to la: ',t);
readln;
end.
ko hiểu đề baì
đề bài làm sao vậy