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.
REFER
uses crt;
var a:array[1..255]of byte;
n,i,kt:integer;
st,st1:string;
begin
clrscr;
write('nhap chieu dai day so:'); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{-------------------------------xu-ly---------------------------------}
st:='';
kt:=0;
for i:=1 to n do
if a[i] mod 2=0 then
begin
str(a[i],st1);
kt:=1;
st:=st+st1;
end;
if kt>0 then
begin
write('doi xung cua cac so chan la: ');
for i:=1 to length(st) do
write(st[i]:4);
for i:=length(st) downto 1 do
write(st[i]:4);
end;
readln;
end.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll i, j, n, a[1000005], dem = 0, m;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for (i = 1; i <= n; i++)
{
cin >> a[i];
if (a[i] % 3 == 0)
{
n--;
i--;
}
}
for (i = 1; i <= n; i++)
{
cout << a[i] << " ";
}
cout<<endl;
for(i=1;i<=n;i++)
{
if(a[i]%5==0)
{
for(j=i;j<=n;j++)
{
a[j]=a[j+1];
}
n--;
i--;
}
}
for(i=1;i<=n;i++)
{
cout<<a[i]<<" ";
}
return 0;
}
a)
uses crt;
VAR
n, d, i: integer;
BEGIN
clrscr;
Writeln ('Nhap vao n='); readln (n);
d : = 1;
For i: = 1 to n do
d: = d*i;
Writeln ('d=',d);
Readln;
END.
c)
uses crt;
VAR
n, i, demuoc: integer;
BEGIN
clrscr;
Writeln ('Nhap vao n='); readln (n);
demuoc: = 0;
For i: = 1 to n do
If n mod i = 0 then
demuoc : = demuoc + 1;
If demuoc = 2 then
Writeln ('n la so nguyen to')
ELSE
Writeln ('n khong phai la so nguyen to');
Readln ;
END.
Còn phần b bạn tự nghĩ nha!
Chúc bạn học tốt!
MÀY LÀ MỘT CON CHÓ NGU L NHẤT T TỪNG BIẾT
ĐCM HƯƠNG TRÀ
ĐCM HƯƠNG TRÀ
ĐCM HƯƠNG TRÀ
CÁI J QUAN TRONG NHẮC LẠI 3 LẦN NHA CON ĐĨ NGU
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n,t1,t2;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
t1=0;
t2=0;
for (i=1; i<=n; i++)
{
if (a[i]%2==0) t1+=a[i];
else t2+=a[i];
}
cout<<"Tong cac so chan la: "<<t1<<endl;
cout<<"Tong cac so le la: "<<t2;
return 0;
}
Lời giải:
program hotrotinhoc;
var a,b : integer;
s: longint;
t: real;
begin
write('A='); readln(a);
write('B='); readln(b);
s:=a;
s:=s+b;
writeln(s);
s:=0;
s:=a;
s:=s-b;
writeln(s);
s:=0;
s:=a;
s:=s*b;
writeln(s);
t:=a;
t:=t/b;
write(t:1:2);
readln
end.
#include <bits/stdc++.h>
using namespace std;
long long x,n,i,t,dem;
int main()
{
cin>>n;
dem=0;
t=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x%2==0 && x>10) t+=x;
if (x%2!=0 || x<100) dem++;
}
cout<<t<<" "<<dem;
return 0;
}
uses crt;
var k:array[1..50]of integer;
i,n,t:integer;
begin
clrscr;
write('nhap n='); readln(n);
for i:=1 to n do
begin
write('k[',i,']='); readln(k[i]);
end;
t:=0;
for i:=1 to n do
if k[i] mod 2=0 then t:=t+a[i];
writeln(t);
readln;
end.
Program hotrotinhoc;
var k: array[1..50] of integer;
i,n: integer;
t: longint;
begin
write('Nhap so phan tu : '); readln(n);
for i:=1 to n do
begin
write('K[',i,']='); readln(k[i]);
if k[i] mod 2=0 then t:=t+k[i];
end;
write('Tong cac phan tu chan la :',t);
readln
end.
uses crt;
var a:array[1..100]of integer;
n,i,k,dem,dem1:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap k='); readln(k);
dem:=0;
dem1:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then inc(dem);
if a[i] mod k=0 then inc(dem1);
end;
writeln('So phan tu chan la: ',dem);
writeln('So phan tu chia het cho ',k,' la: ',dem1);
readln;
end.
uses crt;
var a:array[1..255]of byte;
n,i,kt:integer;
st,st1:string;
begin
clrscr;
write('nhap chieu dai day so:'); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{-------------------------------xu-ly---------------------------------}
st:='';
kt:=0;
for i:=1 to n do
if a[i] mod 2=1 then
begin
str(a[i],st1);
kt:=1;
st:=st+st1;
end;
if kt>0 then
begin
write('doi xung cua cac so le la: ');
for i:=1 to length(st) do
write(st[i]:4);
for i:=length(st) downto 1 do
write(st[i]:4);
end;
readln;
end.
uses crt;
var st,st1,st2:string;
a:array[1..255]of integer;
n,d,i,dem,x,kt:integer;
begin
clrscr;
write('nhap so n:'); readln(n);
str(n,st);
d:=length(st);
for i:=1 to d do
val(st[i],a[i],x);
st2:='';
dem:=0;
kt:=0;
for i:=1 to d do
if a[i] mod 2<>0 then
begin
kt:=1;
dem:=dem+1;
str(a[i],st1);
st2:=st2+st1;
end;
if kt>0 then
begin
write('doi xung cua phan con lai sau khi xoa bot cac so chan la: ');
for i:=1 to dem do
write(st2[i]);
for i:=dem downto 1 do
write(st2[i]);
end;
readln;
end.