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.

1:

uses crt;

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

i,n:integer;

begin

clrscr;

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

for i:=1 to n do

  begin

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

end;

for i:=1 to n do 

  write(a[i]:4);

readln;

end.

2: 

uses crt;

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

i,n,j,tam:integer;

begin

clrscr;

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

for i:=1 to n do

  begin

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

end;

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;

for i:=1 to n do 

  write(a[i]:4);

readln;

end.

3:

uses crt;

var x,i,max:integer;

begin

clrscr;

repeat

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

until x>0;

max:=0;

for i:=1 to x do 

  if i mod 2=0 then

begin

if max<=i then max:=i;

end;

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

readln;

end.

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.

24 tháng 12 2021

#include <bits/stdc++.h>

using namespace std;

long long n,i,a[1000];

int main()

{

cin>>n;

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

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

for (i=n; i>=1; 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

 

#include <bits/stdc++.h>

using namespace std;

int n,A[100],i,dem=0;

int main()

{

cin>>n;

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

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

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

cout<<A[i]<<" ";

cout<<endl;

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

if (A[i]%2==0) dem++;

cout<<dem;

}

Bài 2: 

#include <bits/stdc++.h>

using namespace std;

string st;

int d;

int main()

{

getline(cin,st);

d=st.length();

cout<<d;

return 0;

}

19 tháng 1 2022

Bài 1:

Var so,i,n,dem:integer;

Begin

Write('Nhap so luong so n = ');readln(n);

For i:=1 to n do

Begin

Write('Nhap so thu ',i);readln(so);

If so mod 2 = 0 then dem:=dem+1;

End;

Write('Co ',dem,' so chan');

Readln;

End.

Bài 2:

Var st:string;

Begin

Write('Nhap vao xau ki tu ');readln(st);

Write(' Xau vua nhap co do dai la ',length(st));

Readln;

End.

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

10 tháng 12 2021

#include <bits/stdc++.h>

using namespace std;

long long a[100],b[100],c[100],n,i,dem1,dem2;

int main()

{

cin>>n;

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

cin>>a[i];

dem1=0;

dem2=0;

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

{

if (a[i]%2==0) 

{

dem1++;

b[dem1]=a[i];

}

else 

{

dem2=0;

c[dem2]=a[i];

}

}

sort(b+1,b+dem1+1);

sort(c+1,c+dem2+1);

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

cout<<b[i]<<" ";

for (i=dem2; i>=1; i--)

cout<<c[i]<<" ";

return 0;

}

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

}