You are on page 1of 17

K L UNIVERSITY

FRESHMAN ENGINEERING DEPARTMENT


A Project Based Lab Report

On

<TEDDY AND TRACY >

SUBMITTED BY:

I.D NUMBER NAME

2100031806 A.SRI LAXMI KEERTHI

2100031808 N.BINDU PRIYA

2100031810 B.PRANAVI

2100031813 N.CH.RAMANUJA CHARYULU

UNDER THE ESTEEMED GUIDANCE OF

Mr.B.ASHOK KUMAR

Assistance Professor

KL UNIVERSITY
Green fields, Vaddeswaram – 522 502
Guntur Dt., AP, India.

1
DEPARTMENT OF BASIC ENGINEERING SCIENCES

CERTIFICATE

This is to certify that the project based laboratory report entitled


“<TEDDY AND TRACY>” submitted by Mr./Ms. A.KEERTHI,N.BINDHU
PRIYA,B.PRANAVI,N.CH.RAMANUJA CHARYULU bearing Regd. No.
2100031806,2100031808,210031810,210031813 to the Department of Basic
Engineering Sciences, KL University in partial fulfillment of the requirements
for the completion of a project in “Object Oriented Programming” course in I B
Tech II Semester, is a bonafide record of the work carried out by him/her under
my supervision during the academic year 2019-20.

PROJECT SUPERVISOR HEAD OF THE DEPARTMENT

Mr. B.ASHOK KUMAR Dr. D.HARITHA

2
ACKNOWLEDGEMENTS

It is great pleasure for me to express my gratitude to our honorable


President Sri. Koneru Satyanarayana, for giving the opportunity and platform
with facilities in accomplishing the project based laboratory report.

I express the sincere gratitude to our director Dr. A Jagadeesh for his
administration towards our academic growth.

I express sincere gratitude to our Coordinator and HOD-BES Dr. D.Haritha


for her leadership and constant motivation provided in successful completion of
our academic semester. I record it as my privilege to deeply thank for providing
us the efficient faculty and facilities to make our ideas into reality.

I express my sincere thanks to our project supervisor <name> for his/her


novel association of ideas, encouragement, appreciation and intellectual zeal
which motivated us to venture this project successfully.

Finally, it is pleased to acknowledge the indebtedness to all those who


devoted themselves directly or indirectly to make this project report success.

Name: <NAME>

Regd . No: <IDNO>

3
ABSTRACT

Teddy and Tracy like to play a game based on strings. The game is as follows. Initially,
Tracy writes a long random string on a whiteboard. Then, each player starting with
Teddy makes turn alternately. Each turn, the player must erase a contiguous
substring that exists in the dictionary.

The dictionary consists of N words.

Of course, the player that can’t erase any substring in his turn loses the game, and the
other player is declared the winner.
Note that after a substring R is erased, the remaining substring becomes separated, i.e.
they cannot erase a word that occurs partially to the left of R and partially to the
right of R. Determine the winner of the game, assuming that both players play
optimally.

Input

The first line contains a single integer T, the number of test cases. T test cases follow. The
first line of each test case contains a string S, the string Tracy writes on the whiteboard. The
next line contains a single integer N. N lines follow. The i-th line contains a single string wi, the
i-th word in the dictionary.

Output

For each test case, output a single line containing the name of the winner of the game.

4
INDEX
S.NO TITLE PAGE NO

1 Introduction 6,7

2 Aim of the Project 8

2.1 Advantages & Disadvantages 8

2.2 Future Implementation 8

3 Software & Hardware Details 9

4 Class Diagram 10,11

5 Implementation 13,14

6 Outputs/ScreenShots 15,16

7 Conclusion 17

5
INTRODUCTION
Teddy and Tracy like to play a game based on strings. The game is as follows. Initially,
Tracy writes a long random string on a whiteboard. Then, each player starting with
Teddy makes turn alternately. Each turn, the player must erase a contiguous
substring that exists in the dictionary.

The dictionary consists of N words.

Of course, the player that can’t erase any substring in his turn loses the game, and
the other player is declared the winner.

Note that after a substring R is erased, the remaining substring becomes separated, i.e.
they cannot erase a word that occurs partially to the left of R and partially to the right of
R. Determine the winner of the game, assuming that both players play optimally.

In this projects we have used the concepts of strings , Ioops,arrays, conditional


statements like if else and specially we have used a string STRSTR().

Strings in C
Strings are defined as an array of characters. The difference between a character array
and a string is the string is terminated with a special character ’\0‘.

DecTaratlon of strings: Declaring a string is as simple as declaring a one dimensional


array.

Below is the basic syntax for declaring a


string. Syntax:
char str name[size] ;
In the above syntax str name is any name gi’ven to the string variable and size is used
define the length of the string, i.e the number of characters strings will store. Please
keep in mind that there is an extra terminating character which is the Null character
(‘\0’) used to indicate

Termination of string which differs strings from normal character arrays

6
This program takes string and its substring as input and removes the substring from the
string.

Take a string and its substring as input.

Put each word of the input string into the rows of2-D

array. Search for the substring in the rows of 2-D

array.

When the substring is got, then override the current row with next row and so on
upto
the last row.
You need to often manipulate strings according to the need of a problem. Most, if
not all, of the time string manipulation can be done manually but, this makes
programming complex and large.
To solve this, C supports a large number of string handling functions in the standard
library String.h.

Few commonly used string handling functions are


strlen(),strcpy(),strcat(),strcmp(),etc....

 Strstr( ) function searches the given strine ill the specified main string and
returns the pointer to the first occurrence of the given string.

 Therefore it is necessary to include string header file to use standard


C

string libraryfunction strstr( ).

C strstr() function declaration

7
char *strstr(const char *str, const char*searchstrlng)

 str — The string to be searched.


 searchstring — The string that we need to search in string str

AIM OF THE PROJECT

* It is based on the strings and the substring are erased from


the given string by the players based on words in dictionary.
Advantages:-

 C string are very fast in processing because it stored in array and we


utilize array indexing to accessing part of string or whole.
 Compile-time allocation and determination of size.

Disadvantages:-

 Fixed size.

 Primitive C arrays do not track their own size, so programmer


has
to be careful about boundaries
 While there are some library functions that work with C-strings,
programmer still has to be careful to make correct calls. These library
functions do not protect boundaries either!
 Less intuitive notation for such usage (library features)

Future enhancements:-

 We can write the program for finding the substring from the given string
without using library function i.e. strstr().
We can build many programs with stings and arrays by using different concepts
as like of this project

8
SYSTEM REQUIREMENTS

 SOFTWARE REQUIREMENTS:
The major software requirements of the project are as follows:
Language : Turbo-C
Operating system: Windows Xp or later.

 HARDWARE REQUIREMENTS:
The hardware requirements that map towards the software are as follows:

RAM :8 GB

Processor : i5

9
CLASS DIAGRAM

10
11
ALGORITHM
Step 1: Start

Step 2: Read t,b[100],k

Declare j

Step 3: 3.1:for(k=0;k<t;k+ +)

12
Begin

3.2:Read s[100],s,n

Declare n,I,c=0

3.3:For(i=0;i<n;i++)

Begin

3.4:Read a[100],"p

3.5:p =strstr(s,a)

ifp)

C=C+1

end

B[k]=c

end

Step 4: 4.1for(j=0;j<t:j++)

Begin

4.2: If b[j]=0||b[]%2==0)

4.2.1:Print "Tracy"

Else

4.2.1:Print 'Teddy"

End

Step 5: Stop.

IMPLEMENTATION
#include<stdio.h>

#include<string.h>

int main()

13
{

int t,k,b[100],j;

scanf("%d",&t);

for(k=0;k<t;k++)

char s[100];

int n,i,c=0;

scanf("%s",s);

scanf("%d",&n);

for(i=0;i<n;i++)

char a[100],*p;

scanf("%s",a);

p=strstr(s,a);

if(p)

c++;

b[k]=c;

for(j-0;j<t;j++)

if(b[j]=0||b[j]%2==0)

printf("Tracy\n");

else

14
printf("Teddy\n");

return 0;

OUTPUTS
Screen Shots:

15
16
CONCLUSION

 By this project we under stood the concepts of strings and know how to

how to get substring from the given string and got all the several string

library functions used to manipulate strings and understood and finished the

project and getting outputs for the given inputs.

17

You might also like