Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Solve in C with basic functions and no gets functions please. Thank you. Handle Generator Objective Give practice with reading and writing to standard input

Solve in C with basic functions and no gets functions please. Thank you.

image text in transcribedimage text in transcribed

Handle Generator Objective Give practice with reading and writing to standard input in C. Give practice with loops and conditionals in C. Story You have just entered the mystical Gameland and you wish to earn some coins. There is a low paying beurotractic job you have been granted. It's fairly simple. You will take in someone's name and generate a handle based on it. The rules for generating a handle are pretty simple. 1. Any letter that is not the first or last letter of a name is removed and 2. any spaces are removed as well. For example John Smith becomes JnSh. You have a lot of names to process, so you decided to write a program to do the work for you so you can do other things while the money comes in. Problem Given a list of newline-separated names consisting of only upper and lower case letters and spaces, generate a handle for each using the given rules. Input Input will begin with a line containing 1 integers, n (1 sns 100,000), representing the number of names to process. The following n lines will each contain a single name to process. Each name will have at most 100,000 characters of which can be upper or lower case Latin letters or spaces. Each name will have at least one non-space character. Output Output should contain n lines. Each line will contain a corresponding resulting handle based on the input. Sample Input Sample Output 3 John Smith Travis Meade John Jacob Jingleheimer Schmidt Jnsh TsMe JnJbJrst Helloworld 1 Handsome lionel oversaw october lard Explanation Case 1 There are 3 names "John Smith", "Travis Meade", and "John Jacob Jingleheimer Schmidt'. The rules state that each needs to have the non-starting/ending characters removed. Hints Reading Input: I recommend reading in the first number using traditional scanf. Then use a loop to process each name (maybe with a function). The name processing should involve reading in each character of the name until a new line character is reached, but be careful, since there might be a newline character at the end of the line with the number of names. For "John Smith" we remove "oh' and 'mit". After which we remove the space and are left with "JnSh" For "Travis Meade" we remove "ravi" and "ead" and the space. Which gives us "TsMe". For "John Jacob Jingleheimer Schmidt", we remove "oh", "aco", "ingleheime", and "chmidt" and the three spaces. The remaining letters are "JnJburst". Case 2 There is only one name (phrase?). The name is "Handsome lionel oversaw October lard". The non-space letters to remove are "andsom", "ione", "versa", "ctobe", and "ar". After removing the spaces we have "Helloworld" left over

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

Step: 3

blur-text-image

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

Practical Issues In Database Management A Refernce For The Thinking Practitioner

Authors: Fabian Pascal

1st Edition

0201485559, 978-0201485554

More Books

Students also viewed these Databases questions