K
Khách

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.

Bài 1:

uses crt;
var x,i,t,dem:longint;
tbc:real;
begin
clrscr;
write('nhap x=');readln(x);
t:=0;
dem:=0;
for i:=1 to x do
if x mod i=0 then
begin
t:=t+i;
inc(dem);
end;
tbc:=t/dem;
writeln('trung binh cong cac phan tu la uoc cua ',x,' la: ',tbc:4:2);
readln;
end.

Bài 3:

uses crt;
var a:array[1..100]of integer;
m,n,i:integer;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{----------------------------------------------------}
write('m='); readln(m);
for i:=1 to n do
if a[i]<0 then a[i]:=m;
for i:=1 to n do
write(a[i]:4);
readln;
end.

Bài 4:

uses crt;
var a:array[1..100]of integer;
n,i,j:integer;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{----------------------------------------------------}
for i:=1 to n do
for j:=i+1 to n do
if (a[i] mod a[j]=0) then writeln(a[i],' ',a[j]);
if a[j] mod a[i]=0 then writeln(a[j],' ',a[i]);
readln;
end.

Bài 5:

uses crt;
var a:array[1..100]of integer;
n,i,j:integer;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{----------------------------------------------------}
for i:=1 to n do
for j:=i+1 to n do
if a[i]=sqr(a[j]) then writeln(a[i],' ',a[j]);
if a[j]=sqr(a[i]) then writeln(a[j],' ',a[i]);
readln;
end.

Bài 6:

uses crt;
var a:array[1..100]of integer;
n,i,j:integer;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{----------------------------------------------------}
for i:=1 to n do
for j:=i+1 to n do
if sqr(a[i])+sqr(a[j])=100 then writeln(a[i],' ',a[j]);
if sqr(a[j])+sqr(a[i])=100 then writeln(a[j],' ',a[i]);
readln;
end.

Bài 7:

uses crt;
var a:array[1..100]of integer;
n,i,t1,t2:integer;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{----------------------------------------------------}
t1:=0;
t2:=0;
for i:=1to n do
begin
if i mod 2=0 then t1:=t1+a[i]
else t2:=t2+a[i];
end;
if t1=t2 then writeln('thoa man')
else writeln('khong thoa man');
readln;
end.

Bài 8:

uses crt;
var a,b:array[1..100]of integer;
n,i,kt,j,dem:integer;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{----------------------------------------------------}
dem:=0;
for i:=1 to n do
if i mod 2=0 then
begin
dem:=dem+1;
b[dem]:=a[i];
end;
kt:=0;
for j:=1 to dem-1 do
if a[j]>a[j+1] then kt:=1;
if kt=0 then writeln('cac phan tu o vi tri chan cua day tang dan')
else writeln('cac phan tu o vi tri chan cua day khong tang dan');
readln;
end.

Bài 9:

uses crt;
var a,b,c:array[1..100]of integer;
n,i,j,dem,dem1:integer;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{----------------------------------------------------}
for i:=1 to n do
begin
if i mod 2=1 then
begin
dem:=dem+1;
b[dem]:=a[i];
end
else begin
dem1:=dem1+1;
c[dem1]:=a[i];
end;
end;
for i:=1 to dem do
write(b[i]:4);
for j:=1 to dem1 do
write(c[j]:4);
readln;
end.

25 tháng 2 2020

Cảm ơn bạn nhiều!

10 tháng 3 2021

Bài 1:

#include <bits/stdc++.h>

using namespace std;

long long x,n,i,t;

int main()

{

cin>>n;

t=0;

for (i=1; i<=n; i++)

{

cin>>x;

if ((x<0) and (x%2!=0)) t=t+x;

}

cout<<t;

return 0;

}

#include <bits/stdc++.h>

using namespace std;

long long a[10000],i,n;

int main()

{

cin>>n;

for (i=1; i<=n; i++) cin>>a[i];

for (i=1; i<=n; i++) cout<<a[i]<<"     ";

cout<<endl;

t=0;

for (i=1; i<=n; i++) if (a[i]%2==0) t+=a[i];

cout<<"Tong cac so chan la: "<<t<<endl;

sort(a+1,a+n+1);

cout<<"Day so giam dan la: ";

for (i=n; i>=1; i--) cout<<a[i]<<" ";

return 0;

}

25 tháng 2 2022

Nhưng mà cái này dùng theo pascal và theo kiểu mảng ạ

#include <bits/stdc++.h>

using namespace std;

long long a[1000],i,n;

int main()

{

cin>>n;

for (i=1; i<=n; i++) cin>>a[i];

for (i=1; i<=n; i++) cout<<a[i]<<"     ";

cout<<endl;

cout<<"Cac so duong la: ";

for (i=1; i<=n; i++) if (a[i]>0) cout<<a[i]<<" ";

cout<<endl;

for (i=1; i<=n; i++) if (a[i]%2==0) cout<<a[i]<<" ";

for (i=1; i<=n; i++) if (a[i]%2!=0) cout<<a[i]<<" ";

return 0;

}

#include <bits/stdc++.h>

using namespace std;

long long a[1000],n,i;

int main()

{

cin>>n;

for (i=1;i<=n; i++) cin>>a[i];

for (i=1;i<=n; i++) cout<<a[i]<<"     ";

cout<<endl;

for (i=1; i<=n; i++)

if (a[i]%2==0 && a[i]<0) cout<<a[i]<<" ";

cout<<endl;

for (i=1; i<=n; i++) 

  if (a[i]>0) cout<<a[i]<<" ";

for (i=1; i<=n; i++)

if (a[i]==0) cout<<a[i]<<" ";

for (i=1; i<=n; i++)

if (a[i]<0) cout<<a[i]<<" ";

return 0;

}