rhljain08
BAN USER#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
typedef struct btree
{
struct btree *left;
int data;
struct btree *right;
}btree;
void create(btree *tree1)
{
btree *temp;
int val,choice;
printf("\ndo this have a left childnode of %d?1 or 0\n",tree1->data);
scanf("%d",&choice);
if(choice==1)
{
temp=(btree*)malloc(sizeof(btree));
printf("enter data\n");
scanf("%d",&val);
temp->data=val;
tree1->left=temp;
create(temp);
}
else
tree1->left=NULL;
printf("do this have a right child node of %d?1 or 0\n",tree1->data);
scanf("%d",&choice);
if(choice==1)
{
temp=(btree*)malloc(sizeof(btree));
printf("enter data\n");
scanf("%d",&val);
temp->data=val;
tree1->right=temp;
create(temp);
}
else
tree1->right=NULL;
}
btree* convert(btree *root,btree **head)
{
static int i;
btree * start;
if(root!=NULL)
{
if(*head==NULL)
{
*head=root;
start=root;
}
else
{
(*head)->left=root;
(*head)=(*head)->left;
}
convert(root->left,head);
convert(root->right,head);
return start;
}
else
return NULL;
}
void traverse(btree *head)
{
btree *p;
p=head;
while(p!=NULL)
{
printf("%d ",p->data);
p=p->left;
}
}
main()
{
btree *tree1,*start;
int val;
tree1=(btree*)malloc(sizeof(btree));
if(tree1!=NULL)
{
printf("enter data of root node\n");
scanf("%d",&val);
tree1->data=val;
create(tree1);
}
btree * head;
head=NULL;
head=convert(tree1,&head);
traverse(head);
getch();
}
#include<iostream>
- rhljain08 August 12, 2012using namespace std;
#include<string.h>
main()
{
char str[100];
cin>>str;
char c;
fflush(stdin);
c=getchar();
int i,len;
len=strlen(str);
i=0;
while(c!='\n')
{
if(c==str[i])
{
i++;
if(i==len)
{
cout<<"matched";
break;
}
}
else if(c==str[0])
{
i=1;
}
else
{
i=0;
}
c=getchar();
}
if(c=='\n')
cout<<"Did Not Match";
}