Professional Documents
Culture Documents
REG.NO:16BIT0056
11. Assume FLAMES game that tests for relationship has to be implemented using
a dynamic structure. The letters in the FLAMES stand for Friends , Love,
Affection, Marriage, Enmity and Sister. Initially store the individual letters of the
word ‘flames’ in the nodes of the dynamic structure. Given the count of the
number of uncommon letters in the two names ‘n’, write a program to delete every
nth node in it, till it is left with a single node. If the end of the dynamic structure is
reached while counting, resume the counting from the beginning. Display the letter
that still remains and the corresponding relationship Eg., If Ajay and Jack are the
two names, there are 4 uncommon letters in these. So delete 4t h node in the first
iteration and for the next iteration start counting from the node following the
deleted node
CODE:
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
struct node
int num;
};
int main()
{
struct node *head = NULL;
int survive;
create(&head);
display(head);
char a[10];
char b[10];
int i,l1,l2,x=0,k=0,j;
scanf("%s",&a);
scanf("%d",&b);
l1=strlen(a);
l2=strlen(b);
for(i=0;i<l1;i++)
x=0;
for(j=0;j<l2;j++)
if(a[i]==b[j])
x=1;
b[j]=' ';
}
if(x==1)
a[i]=' ';
x=0;
for(i=0;i<l1;i++)
if(a[i]!=' ')
x++;
for(i=0;i<l2;i++)
if(b[i]!=' ')
x++;
if(survive==1)
printf("Relationship is friendship");
else if(survive==2)
printf("Relationship is Love");
else if(survive==3)
printf("Relationship is Affair");
else if(survive==4)
printf("Relationship is Marriage");
else if(survive==5)
printf("Relationship is Enemy");
else if(survive==6)
printf("Relationship is Sister");
free(head);
return 0;
int i;
q = p = *head;
while (p->next != p)
q = p;
p = p->next;
q->next = p->next;
printf("%d has been killed.\n", p->num);
free(p);
p = q->next;
*head = p;
return (p->num);
do
temp->num = a;
temp->next = NULL;
if (*head == NULL)
*head = temp;
else
rear->next = temp;
rear = temp;
a++;
} while (a <= 6);
rear->next = *head;
temp = head;
temp = temp->next;
temp = temp->next;
printf("\n");