K&R Exercise 1-9 (C)

后端 未结 30 1169
北荒
北荒 2021-01-31 19:46

\"Write a program to copy its input to its output, replacing each string of one or more blanks by a single blank.\"

I\'m assuming by thi

30条回答
  •  春和景丽
    2021-01-31 20:32

    #include
    #include
    
    int main(void)
    {
     int c, flag=0;
    
       while((c=getchar()) != EOF){
    
          if(c == ' '){
             if(flag == 0){
                flag=1;
                putchar(c);
            }
        }else{
            flag=0;
            putchar(c);
         }
    
       }
    
      return 0;
    
    }
    

    I hope this will help.

提交回复
热议问题