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 HOC24;
const fi='Cau1.INP';
fo='Cau2.OUT';
var i,a,b,c,t,d: integer;
f: text;
function ucln(x,y: integer): integer;
var t: integer;
begin
while y<>0 do
begin
t:= x mod y;
x:=y;
y:=t;
end;
ucln:=x;
end;
procedure ip;
begin
assign(f,fi);
reset(f);
read(f,a,b,c);
close(f);
end;
procedure out;
begin
assign(f,fo);
rewrite(f);
for i:=b to c do
begin
if i mod a=0 then write(f,i,' ');
t:=t+i;
end;
writeln(f);
while t<>0 do
begin
t:=t div 10;
inc(d);
end;
writeln(f,d);
if ucln(a,b,c)=1 then write(f,1) else write(f,0);
close(f);
end;
begin
ip;
out;
end.
#include <bits/stdc++.h>
using namespace std;
long long n,i,x,t,dem,j;
int main()
{
cin>>n;
x=n;
t=0;
while (n>0)
{
t=t+n%10;
n=n/10;
}
cout<<t;
dem=0;
for (i=2; i<=x; i++)
{
bool kt=true;
for (j=2; j*j<=i; j++)
if (i%j==0) kt=false;
if (kt==true) dem++;
}
cout<<dem;
return 0;
}
```cpp
#include <iostream>
#include <vector>
#include <algorithm>
int main() {
int n;
std::cout << "Enter the number of integers (n < 10^5): ";
std::cin >> n;
std::vector<int> numbers(n); std::cout << "Enter " << n << " integers: "; for (int i = 0; i < n; ++i) { std::cin >> numbers[i]; } int sumOfOdd = 0; for (int i = 0; i < n; ++i) { if (numbers[i] % 2 != 0) { sumOfOdd += numbers[i]; } } std::sort(numbers.begin(), numbers.end()); std::cout << "Sum of odd integers: " << sumOfOdd << std::endl; std::cout << "Sorted sequence: "; for (int i = 0; i < n; ++i) { std::cout << numbers[i] << " "; } std::cout << std::endl; return 0;
}
```
program abcdef;
uses Crt;
var
k, lowerLimit, upperLimit, i, j, reversed, temp, remainder: integer;
isPrime, isPalindrome: boolean;
begin
clrscr;
write('Nhap so chu so k (1<=k<=9): ');
readln(k);
lowerLimit := 1;
for i := 1 to k - 1 do
lowerLimit := lowerLimit * 10;
upperLimit := lowerLimit * 10 - 1;
writeln('Cac so nguyen to doi xung co ', k, ' chu so la:');
for i := lowerLimit to upperLimit do
begin
// Kiểm tra số nguyên tố
isPrime := True;
if i < 2 then
isPrime := False
else
for j := 2 to trunc(sqrt(i)) do
if i mod j = 0 then
beginisPrime := False;break;end;
// Kiểm tra số đối xứng
if isPrime then
begin
reversed := 0;
temp := i;
while temp <> 0 dobeginremainder := temp mod 10;
reversed := reversed * 10 + remainder;
temp := temp div 10;
end;
isPalindrome := (i = reversed);
if isPalindrome then
writeln(i);
end;
end;
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a,b,c;
bool kt;
int main()
{
cin>>a>>b>>c;
kt=false;
if (a==(b+c)/2) kt=true;
if (b==(a+c)/2) kt=true;
if (c==(b+a)/2) kt=true;
if (kt==false) cout<<"Khong lap duoc";
else cout<<"Lap duoc";
return 0;
}
lưu ý: dùng C++ và dùng lệnh for
#include <iostream>
using namespace std;
int main()
{
int i,n,a,b,kt,j;
cout<<"a="; cin>>a;
cout<<"b="; cin>>b;
for (i=a; i<=b; i++)
{
if (i>2)
{
kt=0;
for (j=2; j<=i-1; j++)
if (i%j==0) kt=1;
if (kt==0) cout<<i<<" ";
}
}
return 0;
}