Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //https://www.facebook.com/CungHocLapTrinhUIT/?ref=bookmarks
- #include <iostream>
- using namespace std;
- void Nhap(float a[], int &n)
- {
- cout << "Nhap so phan tu n: ";
- cin >> n;
- cout << "Nhap mang: " << endl;
- for (int i = 0; i < n; i++)
- {
- cout << "Nhap phan tu thu " << i + 1 << " : ";
- cin >> a[i];
- }
- }
- int CuoiCung(float a[], int n)
- {
- for (int i = n - 1; i > 0; i--)
- {
- if (a[i] < 0 && a[i] >= -1.0f)
- return i;
- }
- return -1;
- }
- int main()
- {
- float a[100];
- int n;
- Nhap(a, n);
- int ret = CuoiCung(a, n);
- if (ret == -1)
- cout << "Khong co phan tu le\n" << endl;
- else
- cout << "vi tri so le cuoi cung: " << ret << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement