Advertisement
gosuodin

tongchan_cua_mang

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