文章

1

粉丝

0

获赞

12

访问

464

头像
单词翻转 题解:
P3666
发布于2026年3月16日 14:25
阅读数 464

#include <stdio.h>
#include <string.h>
int main() {
	char juzi[10001];
	char word[1000][16];
	int count = 0;
	fgets(juzi, sizeof(juzi), stdin);
	size_t len = strlen(juzi);
	if (len > 0 && juzi[len - 1] == '\n') {
		juzi[len - 1] = '\0';
	}
	char* token = strtok(juzi, " ");
	while (count < 1000 && token != NULL) {
		strcpy(word[count],token);
		count++;
		token = strtok(NULL, " ");
	}
	for (int i = count - 1; i >= 0; i--) {
		printf("%s", word[i]);
		if (i > 0) {
			printf(" ");
		}
	}printf("\n");
	return 0;
}
登录查看完整内容


登录后发布评论

暂无评论,来抢沙发