#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<malloc.h>
#include<stdio.h>
typedef struct flames
{
char c;
struct flames *next;
}flames;
char* relation(char ch);
void main(){
flames *head,*ne2,*ne3,*ne4,*ne5,*ne6,*temp,*p;
char *relate;
int f[6]={0,0,0,0,0,0},n,ch;
char n1[100],n2[100];
clrscr();
cin>>n1;
cin>>n2;
int l1,l2;
l1=strlen(n1);
l2=strlen(n2);
int i,j;
for(i=l1-1;i>=0;i--)
{
if(n1[i]!='\0')
{
for(j=l2-1;j>=0;j--)
{
if(n2[j]!='\0')
{
if(n1[i]==n2[j])
{
n1[i]=n2[j]='\0';
break;
}
}
}
}
}
int count=0;
for(i=0;i<l1;i++)
{
if(n1[i]!='\0')
count=count+1;
}
for(j=0;j<l2;j++)
{
if(n2[j]!='\0')
count=count+1;
}
cout<<"count is "<<count;
printf("\n\nLetters left are %d",count);
//delay(100);
printf("\nchecking for F L A M E S..............\n\n");
///////////////////////////////////////////////////////////
/*Creating CLL for flames*/
head=(struct flames*)malloc(sizeof(struct flames));
ne2=(struct flames*)malloc(sizeof(struct flames));
ne3=(struct flames*)malloc(sizeof(struct flames));
ne4=(struct flames*)malloc(sizeof(struct flames));
ne5=(struct flames*)malloc(sizeof(struct flames));
ne6=(struct flames*)malloc(sizeof(struct flames));
head->c='f'; head->next=ne2;
ne2->c='l'; ne2->next=ne3;
ne3->c='a'; ne3->next=ne4;
ne4->c='m'; ne4->next=ne5;
ne5->c='e'; ne5->next=ne6;
ne6->c='s'; ne6->next=head;
/////displaying CLL
temp=head;
i=0;
while(i<6)
{
printf(" %c",temp->c-32);
temp=temp->next;
i++;
}
printf("\n");
temp=head;
int m=0;
while(m<5)
{
for(i=0;i<count-2;i++)
temp=temp->next;
printf("\nDeleting %c",temp->next->c);
p=temp->next;
temp->next=temp->next->next;
temp=temp->next;
free(p);
m++;
}
ch=temp->c;
printf("\n\tSo.....The Relation is :::::: ");
relate=relation(ch);
//delay(500);
puts(relate);
printf("\n\n");
getch();
}
char* relation(char ch)
{
char *rel;
switch(ch)
{
case 'f':
return rel="FRIENDSHIP";
case 'l':
return rel="LOVE";
case 'a':
return rel="ATTRACTION";
case 'm':
return rel="MARRIAGE";
case 'e':
return rel="ENEMY";
case 's':
return rel="SISTER";
}
}
Saturday, 18 June 2016
c code for FLAMES
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment