lập trình nhập từ bàn phím 1 dãy a có n số thuộc z, và k thuộc z
a, sắp xếp và đưa ra dãy a theo thứ tự tăng dần
b, chèn k vào trong dãy sao cho thứ tự vẫn tăng dần
Nhập mảng dãy số từ bàn phím a in ra tổng các số chia hết cho 3 trong dãy b in ra các số trong khoảng từ 50 đến 100 c sắp xếp dãy theo thứ tự tăng dần và in ra màn hình
mô tả thuật toán và viết chương trình sắp xếp dãy số A gồm N phần tử(N được nhập từ bàn phím) sắp xếp theo thứ tự tăng dần
(pascal)
Viết chương trình nhập một dãy số gồm n số tự nhiên (n nhập từ bàn phím), sắp xếp chúng theo thứ tự tăng dần và in ra màn hình :
a) Dãy đã sắp
b) Các khoảng cách của hai số liền kề (hiệu của hai số đó )
#include <bits/stdc++.h>
using namespace std;
int A[1000],n,i;
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=2; i<=n; i++)
cout<<A[i]-A[i-1]<<endl;
return 0;
}
Đề 1 : Nhập từ bàn phím dãy số gồm phần tử ( n nhập từ bàn phím )
- Dòng 1: In ra dãy số đã sắp xếp theo thứ tự tăng dần
- Dòng 2: In ra các phần tử trong dãy số chia hết cho 3
- Dòng 3: Tính tổng các phân tử trong dãy số là số nguyên tố
Đề 2 ; Nhập từ bàn phím dãy số gồm phần tử ( n nhập từ bàn phím )
- Dòng 1: : In ra dãy số đã sắp xếp theo thứ tự giảm dần
- Dòng 2: In ra các phần tử trong dãy số chia hết cho 5
- Dòng 3: Tính tổng các phân tử trong dãy số là số chính phương
Đề 3 : Nhập từ bàn phím dãy số gồm phần tử ( n nhập từ bàn phím )
- Dòng 1: : In ra dãy số đã sắp xếp những số chia hết cho 5 đứng đầu dãy
- Dòng 2: In ra các phần tử trong dãy số chia hết cho 7
- Dòng 3: Tính tổng các phân tử trong dãy số là số đối xứng có trong dãy số
huhu giúp tớ với
Bài 1 nhập một mảnh vẽ số bất kì từ bàn phím a in ra tổng dãy số đó b in ra giá trị lớn nhất, nhỏ nhất của dãy c sắp xếp dãy theo thứ tự tăng dần
Viết chương trình nhập vào bàn phím một dãy số nguyên gồm n phần tử a.Tính tổng các phương trình có giá trị lẻ b.In ra các số chính phương trong dãy c.In ra các số nguyên tố trong dãy d.Sắp xếp dãy theo thứ tự tăng dần e.Kiểm tra dãy số trên có lập trình cấp số cộng hay không?
uses crt;
var a:array[1..100]of integer;
i,n,t,kt,j:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
t:=0;
for i:=1 to n do
if a[i] mod 2<>0 then t:=t+a[i];
writeln(t);
for i:=1 to n do
if trunc(sqrt(a[i]))=sqrt(a[i]) then write(a[i]:4);
writeln;
for i:=1 to n do
if a[i]>1 then
begin
kt:=0;
for j:=2 to trunc(sqrt(a[i])) do
if a[i] mod j=0 then kt:=1;
if kt=0 then write(a[i]:4);
end;
readln;
end.
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!!!!!!!!!!!!!........
1.Viết chương trình nhập vào một dãy số gồm n phần tử.Sắp xếp dãy số theo thứ tự tăng dần sau đó in ra màn hình dãy số đã sắp xếp. 2.Viết chương trình nhập vào một dãy số gồm n phần tử. Sắp xếp dãy số theo thứ tự giảm dần sau đó in ra màn hình dãy số đã sắp xếp.(cứu mk với mai thi r ạ🥲
1)
Var array:[1..1000] of integer;
i,n,t:integer;
Begin
Write('n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap so thu ',i,' = ');readln(a[i]);
End;
For i:=1 to n do
If a[i] > a[i+1] then
Begin
t:=a[i];
a[i]:=a[i+1];
a[i+1]:=t;
End;
Write('Sap xep tang dan ');
For i:=1 to n do write(a[i]:8);
Readln
End.
2)
Var array:[1..1000] of integer;
i,n,t:integer;
Begin
Write('n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap so thu ',i,' = ');readln(a[i]);
End;
For i:=1 to n do
If a[i] < a[i+1] then
Begin
t:=a[i];
a[i]:=a[i+1];
a[i+1]:=t;
End;
Write('Sap xep giam dan ');
For i:=1 to n do write(a[i]:8);
Readln
End.
Viết chương trình hoàn thành các công việc sau:- Nhập một dãy số có N phần tử (0<N<=100). Yêu cầu :- Sắp xếp dãy số vừa nhập đó theo thứ tự tăng dần.- Tìm một số x nhập từ bàn phím, kiểm tra số x đó có trong dãy số vừa nhập không. Nếu có cho biết vị tríđầu tiên của số x trong dãy, ngược lại thì báo không có số x trong dãy số.- Xóa một số x nhập từ bàn phím, nếu có thì xóa số x đầu tiên trong dãy, ngược lại thì báo không có số xtrong dãy số.- Sửa một số tại vị trí thứ k trong dãy. Nhập vào một vị trí k cần sửa, chương trình cho biết giá trị phần tửở vị trí k đó và yêu cầu nhập giá trị cần sửa.- Chèn một số vào vị trí k, nhập từ bàn phím vị trí k và giá trị cần chèn vào dãy số.- In dãy số hiện hành ra màn hình.- Thoát khỏi chương trình
In ra màn hìnhHAY CHON MOT TRONG CAC SO SAU:1.Nhap day so :2.Sap xep day so :3.Tim mot so :4.Xoa mot so :5.Sua mot so:6.Chen mot so :7.In day so:8.Thoat chuong trinh.