This commit is contained in:
hairrrrr
2020-04-16 20:42:30 +08:00
parent c23f7a528e
commit 836df4a643
3 changed files with 2 additions and 11 deletions

View File

@@ -17,7 +17,7 @@ int main(void) {
// 允许 read_word 函数多读 1 个字符,多读则代表单词长度超过 20需要截断
read_word(word, MAX_WORD_LEN + 1);
word_len = strlen(word);
if (word == 0) {
if (word_len == 0) {
flush_line();
return 0;
}

View File

@@ -47,7 +47,7 @@ void write_line() {
putchar(line[i]);
else {
spaces_to_insert = extra_space / num_words; // 遵循这个公式来增加空格
for (j = 0; j < spaces_to_insert; j++)
for (j = 0; j <= spaces_to_insert; j++) // 使用 = 确保至少打印一个
putchar(' ');
extra_space -= spaces_to_insert;
num_words--;

View File

@@ -45,13 +45,4 @@ void write_line();
*********************************************************/
void flush_line(void);
/********************************************************
*
*
*
*
*
*********************************************************/
#endif