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 người chỉ vote được 1 vote thôi nha bạn !!!

D
datcoder
CTVVIP
25 tháng 6

Hướng dẫn giải:

- Đầu tiên sắp xếp dãy theo thứ tự tăng dần

- Sau khi có 1 dãy số đã được sắp xếp, ta duyệt mảng bắt đầu từ chỉ số đầu tiên. Nếu phần tử thứ i khác phần tử thứ i+1 thì in ra.

Code tham khảo:

1 tháng 7 2023

```cpp
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
int n;
std::cout << "Enter the number of integers (n < 10^5): ";
std::cin >> n;

std::vector&lt;int&gt; numbers(n); std::cout &lt;&lt; &quot;Enter &quot; &lt;&lt; n &lt;&lt; &quot; integers: &quot;; for (int i = 0; i &lt; n; ++i) { std::cin &gt;&gt; numbers[i]; } int sumOfOdd = 0; for (int i = 0; i &lt; n; ++i) { if (numbers[i] % 2 != 0) { sumOfOdd += numbers[i]; } } std::sort(numbers.begin(), numbers.end()); std::cout &lt;&lt; &quot;Sum of odd integers: &quot; &lt;&lt; sumOfOdd &lt;&lt; std::endl; std::cout &lt;&lt; &quot;Sorted sequence: &quot;; for (int i = 0; i &lt; n; ++i) { std::cout &lt;&lt; numbers[i] &lt;&lt; &quot; &quot;; } std::cout &lt;&lt; std::endl; return 0;

}
```

D
datcoder
CTVVIP
3 tháng 11 2023

#include <bits/stdc++.h>

using namespace std;

int main () { int a[1000],n,i;

cin >> n;

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

cin >> a[i];

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

if (((a[i]<0) and (a[i-1]<0)) or ((a[i]>0) and (a[i-1]>0))) {

cout << a[i-1] <<" " << a[i];

break; }

return 0;

}

27 tháng 3 2022

Lưu ý :Dùng C++

30 tháng 10 2021

uses crt;

var a:array[1..50]of int64;

i,n,t,max,min:int64;

begin

clrscr;

readln(n);

for i:=1 to n do 

  readln(a[i]);

max:=a[1];

min:=a[1];

t:=0;

for i:=1 to n do 

begin

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

if min>a[i] then min:=a[i];

t:=t+a[i];

end;

writeln('Tong la: ',t);

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

write('Vi tri la: ');

for i:=1 to n do

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

writeln;

writeln('So nho nhat la: ',min);

write('Vi tri la: ');

for i:=1 to n do 

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

readln;

end.

#include <bits/stdc++.h>

using namespace std;

long long a[1000],n,i;

int main()

{

freopen("dayd.inp","r",stdin);

freopen("dayd.out","w",stdout);

cin>>n;

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

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

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

return 0;

}

15 tháng 4 2021

tự làm đi dễ mà:)))))

 

Dễ thì bạn làm đi

#include <bits/stdc++.h>

using namespace std;

int main()

{

long a[105], i,n,max,vt;

cout<<"n="; cin>>n;

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

{

cout<<"A["<<i<<"]="; cin>>a[i];

}

max=a[1];

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

if (max<a[i]) max=a[i];

vt=1;

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

if (max==a[i]) vt=i;

cout<<max<<endl;

cout<<vt;

return 0;

}

 

10 tháng 10 2022

bài này sai r bạn ơi