Include
Include
if (index == k) {
return;
current[index] = i;
if (k > n) {
cout << "Invalid input: k cannot be greater than n." << endl;
return;
int current[100];
int main() {
combination(k, n);
return 0;
Queston 2:
#include <iostream>
class Node {
public:
int Value;
Node *Next;
Node *Prev;
Node(int Value) {
this->Value = Value;
Next = NULL;
Prev = NULL;
};
class DoublyLL {
public:
Node *Head;
Node *Tail;
DoublyLL() {
Head = NULL;
Tail = NULL;
if (Head == NULL) {
Head = newNode;
Tail = newNode;
} else {
Tail->Next = newNode;
newNode->Prev = Tail;
Tail = newNode;
cout << Value << " has been added!" << endl;
void DeleteFromFront() {
if (Head == NULL) {
return;
Head = Head->Next;
if (Head != NULL) {
Head->Prev = NULL;
} else {
Tail = NULL;
cout << temp->Value << " has been removed from LL!" << endl;
delete temp;
int count = 0;
curr = curr->Next;
return count;
int x = 0;
if (curr1 != nullptr) {
x += curr1->Value;
curr1 = curr1->Next;
if (curr2 != nullptr) {
x += curr2->Value;
curr2 = curr2->Next;
LL.AddToTail(x);
void printList() {
};
int main() {
list1.AddToTail(1);
list1.AddToTail(2);
list2.AddToTail(3);
list2.AddToTail(4);
result.printList();
return 0;