#include #include #include using namespace std; class node { public: int data; node * next; node(int d) { data = d; next = NULL; } }; int rsum(node * head) { if (head == NULL) { return 0; } return head->data + rsum(head->next); } void rprint(node * head) { if (head == NULL) { return; } rprint(head->next); cout << head->data << " "; } int rmax(node * head) { if (head->next == NULL) { return head->data; } int other = rmax(head->next); if (other > head->data) { return other; } return head->data; } bool rfind(node * head, int value) { if (head == NULL) { return false; } return (head->data == value) || rfind(head->next, value); } int main() { node * head = new node(1); head->next = new node(2); head->next->next = new node(3); head->next->next->next = new node(4); rprint(head); cout << endl; cout << "max is " << rmax(head) << endl; cout << "sum is " << rsum(head) << endl; return 0; }