The C programming language-Exercise 1-9
2011-10-17 14:53
375 查看
Write a program to copy its input to its output, replacing each string of one or more blanks by a single blank.
我做的答案是:
我做的答案是:
#include<stdio.h> main() { int c,nb; c=nb=getchar(); while(c != EOF) { while (c == ' ') { nb=c; c=getchar(); } if(nb != ' ') { putchar(c); } else { putchar(nb); putchar(c); } nb=c = getchar(); } }方法很笨,如果你有较好的方法,教我吧。
相关文章推荐
- The C Programming Language Exercise 2_6
- Selected solutions to exercise of "The C Programming Language" 2e (Part 1)
- Selected solutions to exercise of "The C Programming Language" 2e (Part 2)
- Selected solutions to exercise of "The C Programming Language" 2e (Part 3)
- The C Programming Language——Exercise solutions of the chapter one (1st)
- Selected solutions to exercise of "The C Programming Language" 2e (Part 4)
- Selected solutions to exercise of "The C Programming Language" 2e (Part 5)
- Selected solutions to exercise of "The C Programming Language" 2e (Part 6)
- Selected solutions to exercise of "The C Programming Language" 2e (Part 7, End of Chapter 1)
- Library Organization and Containers(Chapter 16 of The C++ Programming Language)
- The C programming language --第一章 基本概念读书笔记
- The Swift Programming Language阅读笔记
- The C++ Programming Language
- The C Programming Language 练习题4-5
- The D Programming Language 书评
- [iOS翻译]《The Swift Programming Language》系列:Welcome to Swift-01
- [iOS翻译]《The Swift Programming Language》 Control Flow - 控制流
- 读经典《C程序设计语言》(The C Programming Language)
- The Swift Programming Language--语言指南--类和结构体
- C++: The Most Powerful Language for .NET Framework Programming