题解 | #单词倒排#
单词倒排
https://www.nowcoder.com/practice/81544a4989df4109b33c2d65037c5836
#include <stdio.h>
#include<string.h>
#include<ctype.h>
int main() {
//输入字符串
char x = 0;
char str[100][22];
//遍历
int i = 0; int j = 0;
while (scanf("%c", &x),x != '\n')
{
if (isalpha(x))
{
str[i][j] = x;
j++;
}
else
{
if (j != 0)
{
str[i][j] = '\0';
i++,j=0;
}
}
}
str[i][j] = '\0';
//打印
for (int count = i; count >= 0; count--)
{
printf("%s ", str[count]);
}
return 0;
}
查看5道真题和解析