The C Programming Language Exercise
1-9 :
Write a program to copy its input to its output, replacing each string of one or more blanks by a single blank.
point : change the entry of space putchar when there has met a space already.
#include <stdio.h> main(){ ; ; while((c = getchar()) != EOF){ if(c == ' '){ ){ putchar(c); inspace = ; } } else{ inspace = ; putchar(c); } } }
count the numbers of word:
#include <stdio.h> #define IN 1 //no ";" #define OUT 0 main(){ int c ; int state = OUT; int nc, nw, nl; nc = nw = nl = ; //注意初始化 while((c = getchar()) != EOF){ nc ++; if(c == '\t') nl++; if(c == ' ' || c == '\t' || c == '\n') { state = OUT; } else if(state == OUT){ //if state is OUT here, means in the word, chage state and ++nw state = IN; nw++; } } printf("%d %d %d",nc, nw, nl); }
design a program output the result that every line contains only a word
#include <stdio.h> #define IN 1 //no ";" #define OUT 0 main(){ int c ; ; while((c = getchar()) != EOF){ if(c == ' ' || c == '\t' || c == '\t'){ ){ inspace = ; putchar('\n'); } } else{ inspace = ; putchar(c); } } ; }
The C Programming Language Exercise的更多相关文章
- The Go Programming Language. Notes.
Contents Tutorial Hello, World Command-Line Arguments Finding Duplicate Lines A Web Server Loose End ...
- iOS Swift-元组tuples(The Swift Programming Language)
iOS Swift-元组tuples(The Swift Programming Language) 什么是元组? 元组(tuples)是把多个值组合成一个复合值,元组内的值可以使任意类型,并不要求是 ...
- iOS Swift-控制流(The Swift Programming Language)
iOS Swift-控制流(The Swift Programming Language) for-in 在Swift中for循环我们可以省略传统oc笨拙的条件和循环变量的括号,但是语句体的大括号使我 ...
- iOS Swift-简单值(The Swift Programming Language)
iOS Swift-简单值(The Swift Programming Language) 常量的声明:let 在不指定类型的情况下声明的类型和所初始化的类型相同. //没有指定类型,但是初始化的值为 ...
- Java Programming Language Enhancements
引用:Java Programming Language Enhancements Java Programming Language Enhancements Enhancements in Jav ...
- The Swift Programming Language 英文原版官方文档下载
The Swift Programming Language 英文原版官方文档下载 今天Apple公司发布了新的编程语言Swift(雨燕)将逐步代替Objective-C语言,大家肯定想学习这个语言, ...
- The Swift Programming Language 中文翻译版(个人翻新随时跟新)
The Swift Programming Language --lkvt 本人在2014年6月3日(北京时间)凌晨起来通过网络观看2014年WWDC 苹果公司的发布会有iOS8以及OS X 10.1 ...
- [iOS翻译]《The Swift Programming Language》系列:Welcome to Swift-01
注:CocoaChina翻译小组已着手此书及相关资料的翻译,楼主也加入了,多人协作后的完整译本将很快让大家看到. 翻译群:291864979,想加入的同学请进此群哦.(本系列不再更新,但协作翻译的进度 ...
- Questions that are independent of programming language. These questions are typically more abstract than other categories.
Questions that are independent of programming language. These questions are typically more abstract ...
随机推荐
- 初遇 dotcloud
逛园子的时候看到新浪SAE,正学习建站呢,好东西.(论环境的影响...) 不过发现新浪SAE只支持 Python2,我更喜欢 Python3 e...找找其他的,发现了 dotcloud,遂试试,下面 ...
- Web前端开发学习心得(一)
说快也快,说慢也慢.自学前端一个月了,进步不算大,不过仔细想来,倒也收获不少.码几行字,一是总结经验,二是继往开来. 刚开始是跟慕课网学的HTML+CSS,慕课网的课程虽然好,但好多知识都是特别基础的 ...
- nsq
官网:http://nsq.io (1)描述 都是message broker,rabbitmq久经考验,nsq则是后起之秀.rabbitmq是erlang编写,nsq是golang. 安装:http ...
- 内网透过公网nginx和vpn实现微信接口调试
条件: 1.公网IP开放80/443端口 2.vpn,我熟悉openvpn 3.nginx反向代理 1.在公网服务器上装nginx和vpnserver 2.本地调试电脑装vpnclient,mac o ...
- 批量修改sql server 2008的架构
--批量修改架构.名称为XJADMINATT的所有表修改为dbo-- --把执行的结果,拷贝到命令行,执行命令即可-- declare @name sysname declare csr1 curso ...
- docker底层技术概览
docker解决了云计算环境难于分发并且管理复杂,而用KVM.Xen等虚拟化又浪费系统资源的问题.Docker最初是基于lxc构建了容器引擎,为了提供跨平台支持,后又专门开发了libcontainer ...
- Linux--01入门
一.远程控制台 Linux和windows不太一样,win系列默认都有桌面,我们买了服务器,一般都用远程桌面去连接. 而linux一般都是为了追求低成本或者高性能,可能我们就不需要桌面了,所以使用命令 ...
- 备份触发器:ADDC3
CREATE OR REPLACE TRIGGER "XMV502"."ADDC3" before insert on bd_cubasdoc for each ...
- Mac下安装nginx
试图折腾了一下手动安装,太多依赖,繁琐的要死.只好装了一个homebrew , 具体安装homebrew的教程网上查吧,就是一句话(ruby -e "$(curl -fsSL https:/ ...
- javascript面向对象之一
问题:怎么动态设置和读取一个对象的属性? <script type="text/javascript"> function User(property){ for( ...