Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Array-01
- #include <iostream>
- using namespace std;
- main()
- {
- int a[5],i;
- for (i=0; i<5; i++)
- {
- cout<<"nhap so "<< "\t" ;
- cin >> a[i];
- }
- cout << "Nhap cac phan tu cua mang: " << endl;
- for (i=0; i<5; i++)
- {
- cout << a[i] << endl;
- }
- int b=a[0];
- for (int i=0; i<5; i++)
- {
- if(b<a[i])
- {
- b=a[i];
- }
- }
- cout << "MAX"<< b<< endl;
- int c=a[0];
- for (int i=0; i<5;i++)
- {
- if (c>a[i])
- {
- c=a[i];
- }
- }
- cout << "MIN"<< c <<endl;
- int temp;
- for (i=0;i<5;i++)
- {
- for (int j=i+1; j<5; j++)
- {
- if (a[i]>a[j])
- {
- temp=a[i];
- a[i]=a[j];
- a[j]=temp;
- }
- }
- }
- cout << "sap xep tu nho den lon:" << endl;
- for (int i = 0; i<5 ; i++)
- {
- cout << a[i] <<endl;
- }
- for (i =0 ; i < 5 ; i++)
- {
- for (int j = i + 1 ; j <5 ; j++)
- {
- if (a[i] < a[j]);
- {
- temp = a[j];
- a[j] = a[i];
- a[i] = temp;
- }
- }
- }
- cout << "sap xep tu lon den be: " << endl;
- for ( i = 0; i < 5; i++)
- {
- cout << a[i] << endl ;
- }
- }
Add Comment
Please, Sign In to add comment