Sie sind auf Seite 1von 14

FRESHMAN ENGINEERING DEPARTMENT

A Project Based Lab Report

On

TRAIN AND PETER

SUBMITTED BY:

Xxxxxxxxxxx

Xxxxxxxxxx

UNDER THE ESTEEMED GUIDANCE OF

xxxxxxx

Assistant Professor

DEPARTMENT OF BASIC ENGINEERING SCIENCES

1
CERTIFICATE

This is to certify that the project based laboratory report entitled


“TRAIN AND PETER” submitted by xxxxxxx
Regd.No.190030803,190030885,190030828,190030887 to the Department of Basic
Engineering Sciences, in partial fulfillment of the requirements for the completion of a
project based Laboratory in “Technical Skills-I(Coding)” course in I B Tech I Semester, is a
bonafide record of the work carried out by him/her under my supervision during the academic
year 2019 – 2020.

PROJECT SUPERVISOR HEAD OF THE DEPARTMENT

xxxxxx xxxxx

ACKNOWLEDGEMENTS

It is great pleasure for us to express my gratitude to our honorable President


XXXXXXX, for giving the opportunity and platform with facilities in accomplishing the
project based laboratory report.

We express the sincere gratitude to our Director XXXX for his administration
towards our academic growth.

2
We express sincere gratitude to our Coordinator XXXXXy and HOD-BES XXXXfor
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.

We express my sincere thanks to our project supervisor XXXX for 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.

ABSTRACT
Peter likes to travel by train. He likes it so much that on the train he falls asleep.Once in
summer Peter was going by train from city A to city B, and as usual, was sleeping. Then he
woke up, started to look through the window and noticed that every railway station has a
flag of a particular colour.

The boy started to memorize the order of the flags' colours that he had seen. But soon he
fell asleep again. Unfortunately, he didn't sleep long, he woke up and went on memorizing
the colours. Then he fell asleep again, and that time he slept till the end of the journey.

At the station he told his parents about what he was doing, and wrote two sequences of the
colours that he had seen before and after his sleep, respectively.

3
Peter's parents know that their son likes to fantasize. They give you the list of the flags'
colours at the stations that the train passes sequentially on the way from A to B, and ask
you to find out if Peter could see those sequences on the way from A to B, or from B to A.
Remember, please, that Peter had two periods of wakefulness.

Peter's parents put lowercase Latin letters for colours. The same letter stands for the same
colour, different letters — for different colours.
Input

The input data contains three lines. The first line contains a non-empty string, whose length
does not exceed 105, the string consists of lowercase Latin letters — the flags' colours at the
stations on the way from A to B. On the way from B to A the train passes the same stations,
but in reverse order.. The third line contains the sequence, written during the second period
of wakefulness. Both sequences are non-empty, consist of lowercase Latin letters, and the
length of each does not exceed 100 letters. Each of the sequences is written in
chronological order.
Output
Output one of the four words without inverted commas:
 «forward» — if Peter could see such sequences only on the way from A to B;
 «backward» — if Peter could see such sequences on the way from B to A;
 «both» — if Peter could see such sequences both on the way from A to B, and on the
way from B to A;
 «fantasy» — if Peter could not see such sequences.

INDEX
S.NO TITLE PAGE NO

1 Introduction 6

2 Aim of the Project 7

2.1 Advantages & Disadvantages 7

4
2.2 Future Implementation 7

3 Software & Hardware Details 8

4 Implementation 10-12

5 Algorithm for each module 9

6 Integration and System Testing 13

7 Conclusion 14

INTRODUCTION
 The project “Train and Peter” is extensively based on the concept of strings.
 It also uses for loop and flag variables
 The project is to find the order of stations which Peter memorized during his period
of wakefulness
 The input of the program is order of stations from destination A to destination B
 The next Two inputs are memorizing order of stations which Peter did during his
two periods of wakefulness respectively
5
AIM
 The project is to find the order of stations which Peter memorized during his period
of wakefulness.
 The elaboration can be done using an example:

aaacaaa - Order of stations from A to B

aca - Memorization during 1st period of wakefulness

aa - Memorization during 2nd period of wakefulness

Output:-

6
Both – It is the output as “aca” , ”aa” are sub strings of the main string in both
forward and backward ways.

 Output should be “Forward” when the substring condition satisfies from left to
right
 Output should be “Backward” when the substring condition satisfies from right to
left.
 Output should be “Fantasy” when none of the above conditions are True

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:

7
RAM :4GB & Above

Processor : i3 & Above

ALGORITHM
1.Start
2.Initialize four flag variables with 0
3.Read strings as input
 Output should be “Forward” when the substring condition satisfies from left to
right
 Output should be “Backward” when the substring condition satisfies from right to
left.
 Output should be “Fantasy” when none of the above conditions are True

5. Stop

8
IMPLEMENTATION
#include<stdio.h>

#include<string.h>

int main()

long long i=0,j=0,k,flag=0,flag2=0,flag3=0,flag4=0,x,y,z;

char T[100020],A[120],B[120];

gets(T);

9
gets(A);

gets(B);

x=strlen(T);

y=strlen(A);

z=strlen(B);

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

k = i;

for(j=0;j<y&&flag==0&&T[k]!='\0';j++,k++)

if(A[j] != T[k])

flag = 0;

break;

if(j == y - 1)

flag = 1;

};

k = i +y;

for(j = 0; j <z&& flag2 == 0 && flag == 1&& T[k] != '\0'; j++)

if(B[j] != T[k])

flag2 = 0;

break;

if(j == z - 1)

10
flag2 = 1;

k++;

for(i =x- 1; i > -1; i--)

k = i;

for(j = 0; j <y&& flag3 == 0 && k > -1; j++)

if(A[j] != T[k])

flag3 = 0;

break;

if(j ==y- 1)

flag3 = 1;

k--;

k = i -y;

for(j = 0; j <z&& flag4 == 0 && flag3 == 1 && k > -1; j++)

if(B[j] != T[k])

flag4 = 0;

break;

if(j == z- 1)

11
{

flag4 = 1;

k--;

if(flag == 1 && flag2 == 1 && flag3 == 1 && flag4 == 1)

printf("both");

else if(flag == 1 && flag2 == 1)

printf("forward");

else if(flag3 == 1 && flag4 == 1)

printf("backward");

else

printf("fantasy"); return 0;}

INTEGRATION AND SYSTEM TESTING


OUTPUTS
Screen Shots:

12
CONCLUSION
 Thus we can Conclude that the order of Memorization of stations by peter can be
easily calculated using the concepts of Loops and Strings

13
14

Das könnte Ihnen auch gefallen