As standard input, an alphabetic string of 30 or less length containing spaces is entered (several spaces may be contiguous). Create a program that outputs 1 if the entered string is a return statement and 0 if it is not a return (you must not output the string before calling the scanf function).
To receive a string with spaces in scanf, use the formatter "%[\n]s" as the .
\n]s"The correct answer must be the full code that is normally compiled by the C language compiler.
(Example)
Input : : nurs es run
The result :1
This is the question The hint is, "When determining a sashimi sentence, you should search for the following characters without checking for spaces. If the space is to the left of the string, increase the index; if it is to the right of the string, decrease the index. You said multiple spaces can be contiguous, so you should use a repeat statement to increase or decrease the index. Refer to '47.1 Determining Hoemun' for instructions on how to determine Hoemun."
That's what it says.
But I'm not sure why you should increase the index when the space is on the left side of the string and decrease the index when it is on the right side of the string.
c
It says to solve the problem using repetitive statements, so you can use a while statement or a for statement.
For the string nurses run, let's say the start index i = 0 and the last index j = 10.(I believe you already know what the index is, why the beginning is 0 and the end is 10.)
At this point, i starts at the far left of the string, and j starts at the far right of the string. I'm moving to the right, j is moving to the left, making sure that the letters i and j point to are the same.
It says that if it's blank, there's no comparison. If what i points to is blank, i must move one space to the right (increase index 1). Conversely, if what j points to is blank, j must move one space to the left (index 1 reduced).
If you don't know anything while solving the problem, please ask me again
In the form of a water supply code,
int isPalindrome (chars[])
{
int result = 1;
int i = 0, j = strlen(s) - 1;
while(i < j)
{
if s[i] == ' ' :
i++;
continue;
if s[j] == ' ' :
j--;
continue;
if s[i] != s[j] :
result = 0;
break;
i++;
j--;
}
return result;
}
I don't need an overlapping loop
542 Unable to install versioned in Google Colab
703 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
546 Understanding How to Configure Google API Key
549 PHP ssh2_scp_send fails to send files as intended
534 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2024 OneMinuteCode. All rights reserved.