Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int tongchan(int a[], int n) {
- if (n <0) {
- return 0;
- }
- else {
- if (a[n] % 2 == 0) {
- return a[n] + tongchan(a, n - 1);
- }
- else {
- return tongchan(a, n - 1);
- }
- }
- }
- void main() {
- int n;
- cout << "nhap n :";
- cin >> n;
- int *a = new int[n];
- for (int i = 0; i < n; i++) {
- cout << "nhap a[" << i+1 << "]";
- cin >> a[i];
- }
- cout << tongchan(a, n);
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement