C - The C Answer (2nd Edition) - Exercise 1-12
2024-08-31 11:55:07
/* Write a program that prints its input one word per line. */ #include <stdio.h> #define IN 1 /* inside a word */
#define OUT 0 /* outside a word */ /* print input one word per line */
main()
{
int c, state = OUT;
while((c = getchar()) != EOF)
{
if(c == ' ' || c == '\n' || c == '\t')
{
if(state == IN)
{
putchar('\n'); /* finish the word */
state = OUT;
}
else if(state == OUT)
{
state = IN; /* beginning of word */
putchar(c);
}
else /* inside a word */
{
putchar(c);
}
}
}
}
最新文章
- Java框架Struts2
- hibernate.cfg.xml配置文件和hbm.xml配置文件
- POJ 1364 King --差分约束第一题
- 虚拟化之xenserver
- Win7系统上配置使用Intellij Idea 13的SVN插件
- C#怎么得到主机名,IP,MAC
- Gmail POP3设定
- vue组件,可以通过npm引用的组件
- 高性能Mysql笔记 — 索引
- HDU 5113
- linux每日命令(12):nl命令
- DQL完整语法及示例
- XML中的变量传值
- 设置linux的console为串口【转】
- shell升级
- 在ASP.NET MVC下实现单个图片上传, 客户端服务端双重限制图片大小和格式, 服务端裁剪图片
- 新的Blog
- 转 C#高性能Socket服务器SocketAsyncEventArgs的实现(IOCP)
- solaris之cpu
- MyEclipse项目如何导入到Eclipse