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.

3:

#include <bits/stdc++.h>

using namespace std;

int A[100],i,n,x,kt;

int main()

{

cin>>n;

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

cin>>x;

kt=0;

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

if (A[i]==x) then kt=1;

if (kt==0) cout<<"NO";

else 

{

for (int i=n; i>=1; i--)

if (A[i]==x) 

{

cout<<A[i];

return 0;

}

}

return 0;

}

4:

#include <bits/stdc++.h>

using namespace std;

int A[100],i,n;

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]<<" ";

return 0;

}

7 tháng 10 2021

eoeo

Bài 1.

Bước 1. Nhập N và dãy số a1,a2,...,aNa1,a2,...,aN

Bước 2. i←1i←1S←0S←0

Bước 3. i←i+1i←i+1

Bước 4. 4.1 Nếu i>Ni>N thì kết thúc thuật toán và đưa ra kết quả.

4.2 ai≥0ai≥0 thì quay lại bước 3

4.3 S←S+aiS←S+ai rồi quay lại bước 3

Câu 4: 

#include <bits/stdc++.h>

using namespace std;

int main()

{

int a[100],n,i,t;

cin>>n;

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

cin>>a[i];

t=0;

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

if (a[i]<0) t=t+a[i];

cout<<t;

return 0;

}

Câu 4: 

#include <bits/stdc++.h>

using namespace std;

int main()

{

int a[100],n,i,t;

cin>>n;

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

cin>>a[i];

t=0;

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

if (a[i]<0) t=t+a[i];

cout<<t;

return 0;

}

Câu 4: 

#include <bits/stdc++.h>

using namespace std;

int main()

{

int a[100],n,i,t;

cin>>n;

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

cin>>a[i];

t=0;

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

if (a[i]<0) t=t+a[i];

cout<<t;

return 0;

}

Câu 4: 

#include <bits/stdc++.h>

using namespace std;

int main()

{

int a[100],n,i,t;

cin>>n;

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

cin>>a[i];

t=0;

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

if (a[i]<0) t=t+a[i];

cout<<t;

return 0;

}

Câu 4: 

#include <bits/stdc++.h>

using namespace std;

int main()

{

int a[100],n,i,t;

cin>>n;

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

cin>>a[i];

t=0;

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

if (a[i]<0) t=t+a[i];

cout<<t;

return 0;

}

uses crt;

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

i,n,dem,dem1,dem2,t:integer;

s:real;

begin

clrscr;

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

for i:=1 to n do 

begin

repeat

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

until a[i]>0;

end;

for i:=1 to n do 

  write(a[i]:4);

writeln;

dem:=0;

for i:=1 to n do

  if a[i]>10 then inc(dem);

writeln('So phan tu lon hon 10 la: ',dem);

dem1:=0;

dem2:=0;

for i:=1 to n do 

begin

if a[i] mod 2=0 then inc(dem1)

else inc(dem2);

end;

writeln('So luong so chan la: ',dem1);

writeln('So luong so le la: ',dem2);

t:=0;

s:=1;

for i:=1 to n do 

  begin

if (i mod 2=0) and (a[i] mod 2<>1) then t:=t+a[i];

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

end;

writeln('Tong cac so o vi tri chan co gia tri le la: ',t);

writeln('Tich cac so o vi tri le co gia tri chan la: ',s:4:2);

writeln('Cac so le la: ');

for i:=1 to n do 

  if a[i] mod 2<>0 then write(a[i]:4);

writeln;

writeln('Cac so chan va lon hon 10 la: ');

for i:=1 to n do 

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

readln;

end.

18 tháng 2 2021

Thank you

29 tháng 12 2020

phần a

29 tháng 12 2020

phần b

31 tháng 12 2021

2:

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

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

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

cout<<endl;

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

return 0;

}

uses crt;

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

i,n,max,dem: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);

writeln;

max:=a[1];

for i:=1 to n do 

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

writeln('So lon nhat la: ',max);

write('Vi tri cua so lon nhat la: ');

for i:=1 to n do 

  if max=a[i] then write(i:4);

writeln;

dem:=0;

for i:=1 to n do 

  if max=a[i] then inc(dem);

writeln('So luong phan tu lon nhat trong day la: ',dem);

readln;

end. 

7 tháng 6 2021

uses crt;
var a:array[1..100000000] of int64;
      n,i,d,max:longint;
begin
        clrscr;
        repeat
                write('Nhap so luong phan tu: '); readln(n);
                if (n<=0) and (n>688886) then writeln('NHAP LAI!');
        until (n>0) and (n<=688886);
        for i:=1 to n do
                begin
                        write('Nhap phan tu thu ',i,': '); readln(a[i]);
                end;
        write('Day so vua nhap: ');
        for i:=1 to n do write(a[i],' ');
        max:=a[1];
        for i:=1 to n do if a[i]>max then max:=a[i];
        writeln;
        writeln('So lon nhat: ',max);
        write('Vi tri cua cac so lon nhat: ');
        for i:=1 to n do if a[i]=max then begin write(i,' '); inc(d) end;
        writeln;
        writeln('So luong so lon nhat: ',d);
        readln;
end.