Easy

Proper nouns always begin with a capital letter, followed by small letters.

Correct a given proper noun so that it fits this statement.

Example

  • For noun = "pARiS", the output should be
    properNounCorrection(noun) = "Paris";
  • For noun = "John", the output should be
    properNounCorrection(noun) = "John".

Input/Output

  • [execution time limit] 0.5 seconds (c)

  • [input] string noun

    A string representing a proper noun with a mix of capital and small English letters.

    Guaranteed constraints:
    1 ≤ noun.length ≤ 10.

  • [output] string

    • Corrected (if needed) noun.

[C] Syntax Tips

// Prints help message to the console
// Returns a string
char * helloWorld(char * name) {
    char * answer = malloc(strlen(name) + 8);
    printf("This prints to the console when you Run Tests");
    strcpy(answer, "Hello, ");
    strcat(answer, name);
    return answer;
}

더보기

Solution

char *properNounCorrection(char *noun)
{
	noun[0]=toupper(noun[0]);
	for(int i=1;i<strlen(noun);i++)
		noun[i]=tolower(noun[i]);

	return noun;
}
728x90

'Codesignal' 카테고리의 다른 글

<Codesignal> Is Case-Insensitive Palindrome?  (0) 2020.04.19
<Codesignal> Is Tandem Repeat?  (0) 2020.04.19
<Codesignal> Enclose In Brackets  (0) 2020.04.18
<Codesignal> Rectangle Rotation  (1) 2020.04.18
<Codesignal> Weak Numbers  (0) 2020.04.18

+ Recent posts