Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1.please write your code in c 2.your code will be judged by the loader code 3.please make sure to pass the test cases All over

1.please write your code in c

2.your code will be judged by the loader code

3.please make sure to pass the test cases

All over the world is now on the road to unsealing, no longer having quarantine for Covid-19. In other words, there is no need for quarantine to enter or leave the country, so people are getting their passports ready to leave the country.

You have a friend who works in a travel agency. When he was helping his customers to apply for passports, he found that people were filling in their names in different cases and filling in the blanks instead of the dash.

The program should be able to input English last name and first name separately. In general, Chinese names have one or two characters for the last name and one or two characters for the first name. The input should be converted to the required format regardless of case.

The format for translating Chinese names into English names is as follows.

1. The first column is the surname (Last name), there should be a space between the two words of the compound surname

2. A half comma and a half blank

3. The second column is the First name, one to two words, with a dash in the middle of the two words.

For example: s English name input, the last name and first name may be entered as "Wang", "Xiao Ming"; "wang", "xiao ming"; "WANG", "XIAO MING" and so on. The correct output results in the English name of "WANG, XIAO-MING".

If it is a name with a compound surname, e.g. "" the English name is: "OU YANG, XIAO-MEI".

Note: The input size is limited to 15 characters, i.e. one of the last name or first name cannot exceed 15 characters, if it exceeds that, "illegal" should be output, and the converted name should not be output.

Input

The first column is the Chinese translation of the English surname (Last name), for example: "Wang".

The second column is the Chinese translation of the English name (First name), for example: "Xiao-Ming".

The input ends with a newline, i.e., both the last name and first name will click a newline after input.

Output

Complete English name in passport format. If either the last name or first name exceeds the required length of 15 characters, "illegal" is output.

Loader Code

Your code will be judge using this program:

#include

#include

#include

#define MAX_LEN 15

void convert (char *last, char *first);

int main()

{

char last_name[MAX_LEN + 2];

char first_name[MAX_LEN + 2];

// Enter last name

fgets(last_name, MAX_LEN*2 , stdin);

if(last_name[strlen(last_name) - 1] == ' ')

last_name[strlen(last_name) - 1] = '\0';

// Enter first name

fgets(first_name, MAX_LEN*2, stdin);

if(first_name[strlen(first_name) - 1] == ' ')

first_name[strlen(first_name) - 1] = '\0';

// Convert and print the name by using the function convert

convert(last_name, first_name);

return 0;

}

Example 1

Input

Wo Ai

Chengshi Sheji

Output

WO AI, CHENGSHI-SHEJI

Example 2

Input

ShEn haI

GuiYU yOUGoUhaochi

Output

illegal

Example 3

Input

WOHAO XINGFEN

A

Output

WOHAO XINGFEN, A

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

Object Oriented Databases Prentice Hall International Series In Computer Science

Authors: John G. Hughes

1st Edition

0136298745, 978-0136298748

More Books

Students also viewed these Databases questions