Advertisement
gosuodin

xenke_am_duong

Jun 7th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. bool xenke(int a[], int n) {
  4. if (n==0) {
  5. return 1;
  6. }
  7. else {
  8. if (a[n] * a[n - 1] < 0) {
  9. return 1 * xenke(a, n - 1);
  10. }
  11. else {
  12. return 0;
  13.  
  14. }
  15. }
  16. }
  17. bool main() {
  18. int n;
  19. cout << "nhap n :";
  20. cin >> n;
  21. int *a = new int[n];
  22. for (int i = 0; i < n; i++) {
  23. cout << "nhap a[" << i+1 << "]";
  24. cin >> a[i];
  25. }
  26. cout << xenke(a, n);
  27. system("pause");
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement