Cho mảng 2 chiều A cấp mxn. Viết chương trình sắp xếp lại mảng A theo yêu cầu sau:
a/ Các phần tử trên mỗi dòng được sắp xếp theo thứ tự giảm dần
b/Các dòng được sắp xếp lại theo thứ tự tăng dần của tổng các phần tử trên mỗi dòng.
viết chương trình thực hiện các yêu cầu sau:nhập vào một mảng gồm n phần tử,hiển thị danh sách các phần tử trong mảngvừa nhập,sắp xếp danh sách các phần tử lẽ trong mảng theo thứ tự giảm dần,hiển thị danh sách các phần tử trong mảng vừa được sắp xếp
Cho dãy số A gồm N phần tử không sắp xếp theo thứ tự. Viết chương trình tính tổng các phẩn tử của dãy số, tìm phần tử có giá trị lớn nhất trong mảng, phẩn tử có giá trị nhỏ nhất trong mảng và vị trí xuất hiện của nó. Sắp xếp dãy số lại theo thứ tự tăng dần. Biết 0<N≤50.
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.
cho mảng số nguyên A gồm n phần tử (N<=100) viết chương trình thực hiện các yêu cầu sau:
-viết thủ tục nhập dữ liệu cho mảng A
-sử dụng thủ tục để sắp xếp lại các mảng theo thứ tự không tăng
uses crt;
var a:array[1..100]of integer;
i,n,dem,t,tb:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
t:=0;
for i:=1 to n do
if a[i]>0 then
begin
dem:=dem+1;
t:=t+a[i];
end;
writeln('So luong phan tu duong la: ',dem);
writeln('Tong cac phan tu duong la: ',t);
writeln('Trung binh cac phan tu duong la: ',t/dem:4:2);
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];
sort(a+1,a+n+1);
for (i=n; i>=1; i--) cout<<a[i]<<" ";
return 0;
}
Viết chương trình nhập vào 1 mảng số nguyên dương gồm có n phần tử (0 < n < 50) từ bàn phím. Sắp xếp lại mảng vừa nhập theo thứ tự giảm dần và lưu mảng sau khi đã sắp xếp vào tệp nhị phân.
Mọi ng giúp e với ạ
Viết chương trình pascal nhập vào một mảng số nguyên B số lượng phần tử là m nhập từ bàn phím
+ sắp xếp mảng theo thứ tự giảm dần rồi in mảng đã sắp xếp ra màn hình
Var a:array[1..1000] of integer;
i,m,tam:integer;
Begin
Write('m = ');readln(m);
For i:=1 to m do
Begin
Write('Nhap so thu ',i,' = ');readln(a[i]);
End;
For i:=1 to m do
If a[i] < a[i+1] then
Begin
tam:=a[i];
a[i]:=a[i+1];
a[i+1]:=tam;
End;
Write('Mang sau khi sap xep: ');
For i:=1 to m do
Write(a[i]:8);
Readln;
End.
1/Viết chương trình nhập vào một mảng số nguyên sắp xếp lại mảng đó theo thứ tự giảm dần
2/ Viết chương trình cho phép nhập vào 1 mảng gồm N phần tử, cho biết số nhỏ nhất trong các số vừa nhập là số thứ mấy
giúp em với ak
Bài 1:
uses crt;
var a:array[1..100]of integer;
i,n,tam,j: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.
Viết chương trình nhập vào mảng n với n nhập từ bàn phím, sắp xếp mảng theo thứ tự giảm dần?(mô tả thuật toán sắp xếp và minh họa cách sắp xếp mảng bằng 1 ví dụ mảng cụ thể).
#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=n; i>=1; i--) cout<<a[i]<<" ";
return 0;
}
1/Cho một dãy số N phần tử . Viết chương trình sắp xếp các phần tử đã cho theo thứ tự tăng dần (giảm dần)
2/ Viết chương trình chèn thêm 1 số nguyên vào 1 dãy số nguyên đã được sắp xếp theo thứ tự tăng dần sao cho dãy số không thay đổi trật tự sắp xếp
GIÚP MIK VỚI SẮP KT 1 TIẾT RÙI!!!!!!!!!!!!!........
Cho mảng một chiều gồm n phần tử thuộc kiểu số nguyên viết chương trình nhâp mảng xuất dữ liệu của mảng đếm và in ra các phần tử chính phương trong mảng sắp xếp các phần tử mảng theo thứ tự số chẵn tăng số lẻ giảm