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.

28 tháng 12 2019

uses crt;
var a,b,c,d:array[1..100]of integer;
n,i,dem,dem1,dem2:integer;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{------------------------------xu-ly------------------------------}
dem:=0;
dem1:=0;
dem2:=0;
for i:=1 to n do
if a[i]<0 then
begin
inc(dem);
b[dem]:=a[i];
end
else if a[i]=0 then
begin
inc(dem1);
c[dem1]:=a[i];
end
else begin
inc(dem2);
d[dem2]:=a[i];
end;
for i:=1 to dem do
write(b[i]:4);
for i:=1 to dem1 do
write(c[i]:4);
for i:=1 to dem2 do
write(d[i]:4);
readln;
end.

#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;

}

Bài 1: 

uses crt;

var a:array[1..100]of integer;

i,n,kt,max,x,j,tam:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do 

  begin

write('A[',i,']='); readln(a[i]);

end;

writeln('Mang ban vua nhap la: ');

for i:=1 to n do 

  write(a[i]:4);

writeln;

for i:=1 to n-1 do 

  for j:=i+1 to n do 

if a[i]>a[j] then 

begin

tam:=a[i];

a[i]:=a[j];

a[j]:=tam;

end;

writeln('Day tang dan la: ');

for i:=1 to n do 

  write(a[i]:4);

writeln;

write('Nhap x='); readln(x);

max:=0;

kt:=0;

for i:=1 to n do 

  if (a[i] mod 2=0) and (a[i]<=x) then 

   begin

  if max<a[i] then max:=a[i];

kt:=1;

end;

if kt=0 then writeln('Trong day khong co so le')

else writeln('So chan lon nhat khong vuot qua ',x,' la: ',max);

readln;

end.

#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;

}

Câu 1:

var a:array[1..100]of integer;

Câu 2: 

uses crt;

var a:array[1..10]of integer;

i:integer;

begin

clrscr;

for i:=1 to 10 do 

  begin

write('A[',i,']='); readln(a[i]);

end;

for i:=1 to 10 do 

 write(a[i]:4);

readln;

end.

Câu 3: 

uses crt;

var a:array[1..15]of integer;

i,n,t:integer;

begin

clrscr;

repeat

write('Nhap n='); readln(n);

until (0<n) and (n<=15);

for i:=1 to n do 

begin

repeat

write('A[',i,']='); readln(a[i]);

until a[i]<=100;

end;

writeln('Mang da nhap la: ');

for i:=1 to n do 

  write(a[i]:4);

writeln;

t:=0;

for i:=1 to n do

if a[i] mod 3=0 then t:=t+a[i];

writeln('Tong cac phan tu chia het cho 3 la: ',t);

writeln('Cac so chan o vi tri le trong day la: ');

for i:=1 to n do 

  if (a[i] mod 2=0) and (i mod 2=1) then write(a[i]:4);

readln;

end.

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;

}

9 tháng 7 2022

#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;
}

#include <bits/stdc++.h>

using namespace std;

double a[100];

int 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;

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

swap(a[i],a[n+1-i]);

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

return 0;

}

24 tháng 2 2022

bn ơi bn làm bằng pascal đc ko ạ, mik cần cả hai cái lun