Back
Mang_Tang_Dan.cpp
Save
// Mang_Tang_Dan.cpp #include
using namespace std; void nhap_mang(int a[], int n) { for (int i = 0; i < n; i++) { cout<<"a["<
>a[i]; } } void kiem_tra_mang(int a[], int n) { int tang = 0, bang = 0, giam = 0; for (int i = 0; i < n-1; i++) { if (a[i] < a[i+1]) { tang++; } if (a[i] == a[i+1]) { bang++; } if (a[i] > a[i+1]) { giam++; } } if (tang == n-1) { cout<<"Mang tang thuc su"; } else if (tang + bang == n-1 && bang != 0) { cout<<"Mang tang dan"; } else if (giam == n-1) { cout<<"Mang giam thuc su"; } else if (giam + bang == n-1 && bang != 0) { cout<<"Mang giam dan"; } else { cout<<"Mang khong co trat tu nao"; } } int main() { int n, a[30]; do { cout<<"Nhap n: "; cin>>n; if (n < 1 || n > 30) cout<<"Nhap so nguyen 1 <= n <= 30"<
30); nhap_mang(a,n); kiem_tra_mang(a,n); return 0; }