Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Plagiarism Scan Report

Summary
Report Genrated Date 29 Mar, 2017
Plagiarism Status 100% Unique
Total Words 226
Total Characters 1312
Any Ignore Url Used

m
Content Checked For Plagiarism:

co
#include
#include

s.
#include
#define bool int
#define true 1 ol
#define false 0
struct Node
To
{
int data;
struct Node *next, *prev;
};
eo

void pairSum(struct Node *head, int x)


{
lS

struct Node *first = head;


struct Node *second = head;
al

while (second->next != NULL)


second = second->next;
Sm

bool found = false;

while (first != NULL && second != NULL &&


first != second && second->next != first)
{
if ((first->data + second->data) == x)
{
found = true;
printf("(%d,%d)\n" , first->data , second->data);

first = first->next;

second = second->prev;
}
else
{
if ((first->data + second->data) < x)
first = first->next;
else
second = second->prev;
}
}

if (found == false)
printf("No pair found");
}

void insert(struct Node **head, int data)


{

m
struct Node *temp;
temp = (struct Node*)malloc(sizeof(struct Node));

co
temp->data = data;
temp->next = temp->prev = NULL;
if (!(*head))
(*head) = temp;

s.
else
{ ol
temp->next = *head;
(*head)->prev = temp;
To
(*head) = temp;
}
}
eo

int main()
{
struct Node *head = NULL;
lS

int i , x , num;
printf("Give the value of x :");
scanf("%d" , &x);
al

printf("Enter the number of elements in the linked list : ");


scanf("%d" , &num);
Sm

for( i =0 ;i < num ; i++){


int n ;
printf("Enter the value of element %d :" , i+1 );
scanf("%d" , &n);
insert(&head , n);
}

pairSum(head, x);

return 0;
}

Report generated by smallseotools.com

You might also like