Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
(Bai) completed
Browse files Browse the repository at this point in the history
  • Loading branch information
truonghoangkhiem committed Nov 17, 2023
1 parent 7391459 commit ca87347
Showing 1 changed file with 50 additions and 2 deletions.
52 changes: 50 additions & 2 deletions Bai187/Source.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,56 @@
#include <iostream>
#include <iomanip>

using namespace std;

int main()
int DemGiaTri(int[], int);
void Nhap(int[], int&);
void Xuat(int[], int);

int DemGiaTri(int a[], int n)
{
if (n == 0)
return 0;
if (n == 1)
return 0;
int dem = DemGiaTri(a, n - 1);
int flag = 1;
for (int i = 0; i <= n - 2; i++)
if (a[i] >= a[n - 1])
flag = 0;
if (flag == 1)
dem++;
return dem;
}


void Nhap(int a[], int& n)
{
cout << "Nhap n: ";
cin >> n;
for (int i = 0; i <= n - 1; i++)
{
cout << "Nhap a[" << i << "]: ";
cin >> a[i];
}
}

void Xuat(int a[], int n)
{
if (n == 0)
return;
Xuat(a, n - 1);
cout << setw(6) << a[n - 1];
}

return 0;
int main()
{
int b[100];
int k;
Nhap(b, k);
cout << "Mang ban dau la: ";
Xuat(b, k);
int kq = DemGiaTri(b, k);
cout << "\nKet qua la: " << kq;
return 1;
}

0 comments on commit ca87347

Please sign in to comment.