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.

30 tháng 4

Mô tả bài toán sắp xếp dãy số tăng dần:

1. Đầu vào (Input):

  • Một dãy số gồm \(n\) phần tử (có thể là số nguyên hoặc số thực).
  • Ví dụ: \(A = \left[\right. 5 , 2 , 9 , 1 , 3 \left]\right.\)

2. Đầu ra (Output):

  • Dãy số sau khi được sắp xếp theo thứ tự tăng dần (từ nhỏ đến lớn).
  • Ví dụ: \(A = \left[\right. 1 , 2 , 3 , 5 , 9 \left]\right.\)

3. Ví dụ minh họa:

  • Input: \(\left[\right. 7 , 4 , 6 , 2 \left]\right.\)
  • Output: \(\left[\right. 2 , 4 , 6 , 7 \left]\right.\)
26 tháng 5

Câu 1.

Đầu vào:
Một dãy số chưa được sắp xếp.

Đầu ra:
Dãy số đã được sắp xếp theo thứ tự tăng dần, từ bé đến lớn.

Ví dụ:
Đầu vào:
5, 2, 8, 1, 4

Đầu ra:
1, 2, 4, 5, 8

Vì các số sau khi sắp xếp phải theo thứ tự từ nhỏ đến lớn nên đây là dãy tăng dần.

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.

27 tháng 3 2022

Lưu ý :Dùng C++

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;

}
```

4 tháng 10 2019

program hotrotinhoc;

var a,b: array[1..8000] of integer;

c,d1: array[1..8000] of ansistring;

j,i,d,d2,n: integer;

t,t1,tg,tg1,st,s: ansistring;

begin

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

for i:=1 to n do

begin

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

write('b[',i,']='); readln(b[i]);

end;

for i:=1 to n do if a[i] mod 2 =0 then

begin

str(a[i],t);

s:=s+t;

end

else

begin

str(a[i],t1);

st:=st+t1;

end;

for i:=1 to n do if b[i] mod 2=0 then

begin

str(b[i],t);

s:=s+t;

end

else

begin

str(b[i],t1);

st:=st+t1;

end;

d:=0;

for i:=1 to length(s) do

begin

inc(d);

c[d]:=s[i];

end;

for i:=1 to d do for j:=i to d do

if c[i]>c[j] then

begin

tg:=c[i];

c[i]:=c[j];

c[j]:=tg;

end;

for i:=1 to d do write(c[i],' ');

d2:=0;

for i:=1 to length(st) do

begin

inc(d2);

d1[d2]:=st[i];

end;

for i:=1 to d2 do

for j:=i to d2 do

if d1[i]<d1[j] then

begin

tg1:=d1[i];

d1[i]:=d1[j];

d1[j]:=tg1;

end;

for i:=1 to d2 do write(d1[i],' ');

readln

end.

2 tháng 10 2021

#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

 

7 tháng 3 2020

program Tin_hoc;

uses crt;

var n,i,j,min:integer;

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

begin

clrscr;

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

writeln('Nhap ',n,' phan tu:');

for i:= 1 to n do begin write('a[',i,']: '); readln(a[i]) end;

for i:= 1 to n do begin

min:=a[i];

If a[i] >0 then for j:= i to n do if a[j] < a[i] then min:= a[j];

write(min,' ') end;

for i:= 1 to n do begin

min:=a[i];

If a[i] <0 then for j:= i to n do if a[j] < a[i] then min:= a[j];

write(min,' ') end;

readln;

end.

Mik ko có thời gian nên chỉ làm thử câu a

Sai thì thôi nha

8 tháng 9 2021

#include <iostream>
using namespace std;
int main()
{
    int n,i,j;
    cout<<"Nhap n="; cin>>n;
    for (i=1; i<=n; i++)
    {
        for (j=i; j<=i+n-1; j++)
            cout<<j<<" ";
        cout<<endl;
    }
    return 0;
}

8 tháng 9 2021

#include <iostream>
using namespace std;
int main()
{
    int t,m,n,ucln;
    cout<<"Nhap n="; cin>>n;
    cout<<"Nhap m="; cin>>m;
    t=m%n;
    while (t!=0)
    {
        t=n%m;
        n=m;
        m=t;
    }
    ucln=n;
    cout<<ucln;
    return 0;
}

8 tháng 9 2021

#include <iostream>
using namespace std;
int main()
{
    int n,i,j;
    cout<<"Nhap n="; cin>>n;
    for (i=1; i<=n; i++)
    {
        for (j=i; j<=i+n-1; j++)
            cout<<j<<" ";
        cout<<endl;
    }
    return 0;
}