Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You will be given a string. You need to write the string character by character into a matrix in a clockwise spiral pattern towards the

You will be given a string. You need to write the string character by character into a matrix in a clockwise spiral pattern towards the center starting from the upper left corner. The length of the given string is not guaranteed to be a perfect square, meaning that not all strings will perfectly spiral towards the center. Some strings will run out of characters before it reaches the center of the matrix. For example, the string length could be 32. You have to find the closest square number that is larger than the string length. In this case it is 36. You will get the square root of the string length, giving you the dimensions of the matrix. In this example, the size will be six by six. As you build the spiral, you will run out of characters to put into the matrix before you finish. However, keep spiralling towards the middle anyways and write periods instead. The string will not have any spaces and will contain letters, numbers, and basic punctuation marks. Each input file will only have one string.

image text in transcribed

Input input1.txt HELLO,HI! Output ./spiral input-inputl.txt output-outputl.txt HEL I!L H,0 ./spiral input-input2.txt output=output2. txt ILOV TLEE A. ST EBEH input2.txt ILOVETHEBEATLES ./spiral input-input2.txt output-output2.txt KEEPA NMYNG 0..EO N. KCL IAHCD input3.txt KEEPAGOLDCHAINONMYNECK

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

Students also viewed these Databases questions