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.
uses crt;
var i,n,t,j,kt:integer;
begin
clrscr;
readln(n);
t:=0;
for i:=2 to n do
if n mod i=0 then
begin
kt:=0;
for j:=2 to trunc(sqrt(i)) do
if i mod j=0 then kt:=1;
if kt=0 then t:=t+i;
end;
write(t);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long i,n,dem;
int main()
{
cin>>n;
dem=0;
for (i=1; i<=n; i++)
if (n%i==0)
{
cout<<i<<" ";
dem++;
}
cout<<endl;
cout<<dem;
return 0;
}
Chương trình đầy đủ:
uses crt;
var n,i:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
if n mod i=0 then write(i:4);
readln;
end.
Câu 1:
uses crt;
var a:array[1..100]of integer;
i,n,t,s:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
s:=1;
dem:=0;
for i:=1 to n do
if a[i] mod 3=0 then
begin
inc(dem);
t:=t+a[i];
s:=s*a[i];
end;
if dem=0 then writeln('Khong co so chia het cho 3 trong day')
else begin
writeln('Tong cac so chia het cho 3 la: ',t);
writeln('Tich cac so chia het cho 3 la: ',s);
end;
readln;
end.
Câu 2:
uses crt;
var a:array[1..100]of integer;
i,n,dem,t: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] mod 2=0 then
begin
inc(dem);
t:=t+a[i];
end;
writeln('So so chan la: ',dem);
writeln('Tong cac so chan la: ',t);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,A[100],dem,t;
cin>>n;
for (int i=1; i<=n; i++)
cin>>A[i];
dem=0; t=0;
for (int i=1; i<=n; i++)
if (A[i]%2==0) dem++;
else t+=A[i];
cout<<dem<<endl;
cout<<t;
return 0;
}
Program HOC24;
var d,i,n,x: integer;
t: longint;
a: array[1..32000] of integer;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Chi so cac phan tu co gia tri bang 0 la: ');
for i:=1 to n do if a[i]=0 then write(i,' ');
writeln;
d:=0; t:=0;
write('Nhap X: '); readln(x);
for i:=1 to n do if a[i]>x then d:=d+1;
writeln('Co ',d,' phan tu co gia tri lon hon ',x);
if n=20 then
begin
for i:=5 to 20 do t:=t+a[i];
end else write('Du lieu da cho chua du 20 phan tu');
write('Tong cac phan tu co gia tri nam trong doan 5 den 20 la: ',t);
readln
end.
uses crt;
var a:array[1..250]of integer;
i,n,t,x,dem:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Chi so cac phan tu co gia tri bang 0 la: ');
for i:=1 to n do
if a[i]=0 then write(i:4);
writeln;
write('Nhap x='); readln(x);
dem:=0;
for i:=1 to n do
if a[i]>x then inc(dem);
writeln('So phan tu lon hon ',x,' la: ',dem);
t:=0;
for i:=1 to n do
if (5<=a[i]) and (a[i]<=20) then t:=t+a[i];
writeln(t);
readln;
end.
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;
}
uses crt;
var t,n,i,dem:integer;
begin
clrscr;
readln(n);
dem:=0;
t:=0;
for i:=0 to n do
if i mod 2=0 then
begin
t:=t+i;
dem:=dem+1;
end;
writeln(dem,' ',t);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long n,dem=0,s=0;
cin >> n;
for (long long i=1;i<=n;i+=2){
dem++;
s+=i;
}
cout << "tu 0 den n co: " << dem << " so le" << endl;
cout << "tong cac so le do la: " << s;
return 0;
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long n,dem=0,s=0;
cin >> n;
for (long long i=1;i<=n;i+=2){
dem++;
s+=i;
}
cout << "tu 0 den n co: " << dem << " so le" << endl;
cout << "tong cac so le do la: " << s;
return 0;
}
var i,n,d:integer;
s:longint;
begin
write('n = ');readln(n);
for i:=1 to n do
if i mod 2 <> 0 then
begin
d:=d+1;
s:=s+i;
end;
writeln('co ',d,' so le');
write('tong cac so le la ',s);
readln;
end.