#embody<stdio.h>
#embody<stdlib.h>
#embody<stdbool.h>
struct
Node
{
int
information;
struct
Node* subsequent;
};
void
push (
struct
Node** head_ref,
int
new_data)
{
struct
Node* new_node =
(
struct
Node*)
malloc
(
sizeof
(
struct
Node));
new_node->information = new_data;
new_node->subsequent = (*head_ref);
(*head_ref) = new_node;
}
bool
isSumSorted(
struct
Node *headA,
struct
Node *headB,
struct
Node *headC,
int
givenNumber)
{
struct
Node *a = headA;
whereas
(a != NULL)
{
struct
Node *b = headB;
struct
Node *c = headC;
whereas
(b != NULL && c != NULL)
{
int
sum = a->information + b->information + c->information;
if
(sum == givenNumber)
{
printf
(
"Triplet Discovered: %d %d %d "
, a->information,
b->information, c->information);
return
true
;
}
else
if
(sum < givenNumber)
b = b->subsequent;
else
c = c->subsequent;
}
a = a->subsequent;
}
printf
(
"No such triplet"
);
return
false
;
}
int
predominant()
{
struct
Node* headA = NULL;
struct
Node* headB = NULL;
struct
Node* headC = NULL;
push (&headA, 20);
push (&headA, 4);
push (&headA, 15);
push (&headA, 10);
push (&headB, 10);
push (&headB, 9);
push (&headB, 4);
push (&headB, 2);
push (&headC, 1);
push (&headC, 2);
push (&headC, 4);
push (&headC, 8);
int
givenNumber = 25;
isSumSorted (headA, headB, headC, givenNumber);
return
0;
}