Màu nền
Font chữ
Font size
Chiều cao dòng
// Sorting.cpp : Defines the entry point for the console application.//Sorting#include "stdafx.h"#include "iostream"#include "conio.h"using namespace std;void Nhapmang(int a[], int &n){ cout<<"Nhap so phan tu: "; cin>>n; for(int i=0;i<n;i++) { cout<<"Nhap phan tu thu "<<i<<"="; cin>>a[i]; } //Xuatmang(a, n);}void Xuatmang(int a[], int n){ cout<<""; for(int i=0;i<n;i++) cout<<" "<<a[i]; cout<<"";}void Interchangesort(int a[], int n){ for(int i=0;i<n-1;i++) for (int j=i+1;j<n;j++) { if(a[i]>a[j]) { int temp=a[i]; a[i]=a[j]; a[j]=temp; } } Xuatmang(a,n);}void selectionsort(int a[], int n){ for(int i=0; i<n-1;i++) { int max=i; for(int j=i+1;j<n;j++) { if(a[max]>a[j]) max=j; } int temp=a[i]; a[i]=a[max]; a[max]=temp; } Xuatmang(a,n);}int _tmain(int argc, _TCHAR* argv[]){ int a[100], n; Nhapmang(a,n); Xuatmang(a,n); //Interchangesort(a, n); selectionsort(a,n); getch();}
Bạn đang đọc truyện trên: TruyenFun.Vip