Sắp Xếp Dãy Số Giảm Dần | VN4000 PASCAL

VN4000 PASCAL

Lý thuyết và Bài tập Lập trình Pascal

  • Home
  • About us

Sắp xếp dãy số Đếm số từ trong một chuỗi.

Sắp xếp dãy số giảm dần

January 2, 2012

vn4000 Ví dụ và Bài tập lập trình Pascal Leave a comment

Chương trình Sắp xếp dãy số giảm dần

chương trình nhập vào một dãy số nguyên có n phần tử . Sắp xếp dãy số theo thứ tự giảm dần & tính giá trị trung bình của dãy.

Program Day_So_Giam_Dan; Uses Crt; Var s,n,i,j,t:integer; a:array[1..20] of integer;

Begin Clrscr; Writeln(‘SAP XEP DAY SO:’); Write(‘Nhap so phan tu cua day n = ‘); Readln(n); For i:=1 to n do Begin

Write(‘a[‘,i,’]= ‘); Readln(a[i]); End; {sap xep day so giam dan} For i:=1 to n-1 do For j:=i+1 to n do If a[i]<a[j] then Begin t:=a[i]; a[i]:=a[j]; a[j]:=t;

End; Writeln(' Day sau khi sap xep giam dan la:'); For i:=1 to n do Write(a[i]:4); Readln; {Tinh trung binh day} s:=0; For i:=1 to n do s:=s+a[i]; Writeln('Gia tri trung binh la: ',s/n:6:2);

Readln;

End.

Share this:

  • Facebook
  • X
Like Loading...

Related

Comments are closed.

Sắp xếp dãy số Đếm số từ trong một chuỗi.

Tìm kiếm

Bài viết mới

  • Bài 29 FULL SCREEN cho DOSBOX
  • Bài 28 Runtime Error 200
  • Bài 27 Một Số Hàm Số
  • Bài 26 Cấu trúc rẽ nhánh và lựa chọn phần 3
  • Bài 25 Cấu trúc rẽ nhánh và lựa chọn phần 2

Danh mục

  • Lý thuyết lập trình Pascal
  • Ví dụ và Bài tập lập trình Pascal

Create a free website or blog at WordPress.com.

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use. To find out more, including how to control cookies, see here: Cookie Policy
  • Reblog
  • Subscribe Subscribed
    • VN4000 PASCAL
    • Sign me up
    • Already have a WordPress.com account? Log in now.
    • VN4000 PASCAL
    • Subscribe Subscribed
    • Sign up
    • Log in
    • Copy shortlink
    • Report this content
    • View post in Reader
    • Manage subscriptions
    • Collapse this bar
%d Design a site like this with WordPress.comGet started

Từ khóa » Viết Chương Trình Sắp Xếp Mảng Tăng Dần Pascal