[SOLVED] CS201 – Homework 3 – String Matching

25.00 $

Category:

Description

Rate

 

Sample Run 1

This program searches a search string in a source string with the option of wildcards.

Example inputs with their meaning in parantheses:

  • thislectureisawesome (to enter a new source string)
  • lecture (to enter a new source string) 2 t?r? (to enter a source string with wildcards)
  • (to exit the program)

Enter your choice and string: 1 changingthesourcestring

Source word has been changed to “changingthesourcestring”

Enter your choice and string: 2 the

For the source word “changingthesourcestring” and search word “the”, “the” has been found at index 8

Enter your choice and string: 2 ing

For the source word “changingthesourcestring” and search word “ing”,

“ing” has been found at index 5

“ing” has been found at index 20

Enter your choice and string: 2 i?g

For the source word “changingthesourcestring” and search word “i?g”,

“ing” has been found at index 5

“ing” has been found at index 20

Enter your choice and string: 2 is

For the source word “changingthesourcestring” and search word “is”, no match has been found.

Enter your choice and string: 2 ?es

For the source word “changingthesourcestring” and search word “?es”,

“hes” has been found at index 9

“ces” has been found at index 15

Enter your choice and string: 2 ?e?

For the source word “changingthesourcestring” and search word “?e?”,

“hes” has been found at index 9

“ces” has been found at index 15

Enter your choice and string: 3

See you!

Sample Run 2

This program searches a search string in a source string with the option of wildcards.

Example inputs with their meaning in parantheses:

  • thislectureisawesome (to enter a new source string)
  • lecture (to enter a new source string) 2 t?r? (to enter a source string with wildcards) 3 (to exit the program)

Enter your choice and string: 1 newsourcestring

Source word has been changed to “newsourcestring”

Enter your choice and string: 1 newsourcestringv2 Wrong input format! Try again.

Enter your choice and string: 1 newsourcestringvtwo Source word has been changed to “newsourcestringvtwo”

Enter your choice and string: 2 ? Wrong input format! Try again.

Enter your choice and string: 2 ??? Wrong input format! Try again.

Enter your choice and string: 2 erf2 Wrong input format! Try again.

Enter your choice and string: 2 sou*ce Wrong input format! Try again.

Enter your choice and string: 2 ?o

For the source word “newsourcestringvtwo” and search word “?o”,

“so” has been found at index 3

“wo” has been found at index 17

Enter your choice and string: 3 See you!

Sample Run 3

This program searches a search string in a source string with the option of wildcards.

Example inputs with their meaning in parantheses:

  • thislectureisawesome (to enter a new source string)
  • lecture (to enter a new source string) 2 t?r? (to enter a source string with wildcards)
  • (to exit the program)

Enter your choice and string: 2 sabanci Wrong input format! Try again.

Enter your choice and string: 1 helloworld? Wrong input format! Try again.

Enter your choice and string: 1 thisissourcestring

Source word has been changed to “thisissourcestring”

Enter your choice and string: 2 this

For the source word “thisissourcestring” and search word

“this”,

“this” has been found at index 0

Enter your choice and string: 2 ?i?

For the source word “thisissourcestring” and search word

“?i?”,

“his” has been found at index 1

“sis” has been found at index 3

“rin” has been found at index 14

Enter your choice and string: 2 t?

For the source word “thisissourcestring” and search word “t?”,

“th” has been found at index 0

“tr” has been found at index 13

Enter your choice and string: 2 thisissourcestring

For the source word “thisissourcestring” and search word

“thisissourcestring”,

“thisissourcestring” has been found at index 0

Enter your choice and string: 2 thisissourcestrin?

For the source word “thisissourcestring” and search word

“thisissourcestrin?”,

“thisissourcestring” has been found at index 0

Enter your choice and string: 2 ?hisissourcestrin?

For the source word “thisissourcestring” and search word

“?hisissourcestrin?”,

“thisissourcestring” has been found at index 0

Enter your choice and string: 5 Choice can be 1, 2 or 3! Try again.

Enter your choice and string: Cs201 Choice can be 1, 2 or 3! Try again.

Enter your choice and string: 3

See you!

Sample Run 4

This program searches a search string in a source string with the

option of wildcards.

Example inputs with their meaning in parantheses:

  • thislectureisawesome (to enter a new source string)
  • lecture (to enter a new source string)
  • t?r? (to enter a source string with wildcards)
  • (to exit the program)

Enter your choice and string: 1 sabanciuniversity

Source word has been changed to “sabanciuniversity”

Enter your choice and string: 2 university

For    the                  source word “sabanciuniversity” and search word

“university”,

“university” has been found at index 7

Enter your choice and string: 2 ab?n

For the source word “sabanciuniversity” and search word “ab?n”, “aban” has been found at index 1

Enter your choice and string: 2 uni?er

For the source word “sabanciuniversity” and search word “uni?er”, “univer” has been found at index 7

Enter your choice and string: 2 un??er

For the source word “sabanciuniversity” and search word “un??er”,

“univer” has been found at index 7

Enter your choice and string: 2 u?i?er

For the source word “sabanciuniversity” and search word “u?i?er”, “univer” has been found at index 7

Enter your choice and string: 2 s???

For the source word “sabanciuniversity” and search word “s???”,

“saba” has been found at index 0

“sity” has been found at index 13

Enter your choice and string: 1 university

Source word has been changed to “university”

Enter your choice and string: 2 sabanciuniversity Wrong input format! Try again.

Enter your choice and string: 2 university

For the source word “university” and search word “university”,

“university” has been found at index 0

Enter your choice and string: 3

See you!