1009 说反话 (PAT)
发布日期:2021-05-10 14:39:53 浏览次数:15 分类:精选文章

本文共 1545 字,大约阅读时间需要 5 分钟。

������������������������C������������������������������������������������������������������

#include 
#include
#include
int main() {
char str[100];
int s, p, e, j, i;
gets(str);
s = strlen(str);
p = s;
// ������������������������������words���
char *words = malloc(p * sizeof(char));
words[0] = '\0';
int word_count = 0;
for (i = s - 1; i >= 0; i--) {
if (str[i] == ' ') {
if (word_count > 0) {
words[word_count] = '\0';
word_count++;
}
j = i + 1;
while (j < s && str[j] != ' ') {
j++;
}
for (k = 0; k < j - i - 1; k++) {
words[word_count + k] = str[i + 1 + k];
}
words[word_count] = '\0';
word_count++;
} else {
// ������������������������������������������
if (i > p) {
// ������������������������������
// (������������������������������������������������������������������������)
}
}
}
if (word_count > 0) {
// ���������������������
printf("%s", words);
}
free(words);
return 0;
}

���������������������������������

  • ���������������������
  • ���������������������������������������������
  • ������������������������������
  • ������������������������
  • ������������������������������������������������������������������������������������������������������������

    上一篇:成绩排序
    下一篇:1006 换个格式输出整数(PAT)

    发表评论

    最新留言

    哈哈,博客排版真的漂亮呢~
    [***.90.31.176]2025年04月26日 13时25分56秒