//打印第一个程序hello, word
#include<stdio.h>
int main() {
printf("hello, world\n");
return ;
}
//将华氏温度转换为摄氏温度,将从0度-300度之间的温度,以20度为一个间隔打印出对应的摄氏温度
#include<stdio.h>
int main()
{
float fahr, //代表华氏温度的变量
celsius; //代表摄氏温度的变量 float bottom = , //起始温度
step = , //温度变化单元
upper = ; //最高温度 fahr = bottom;
while (fahr <= upper) {
celsius = (5.0 / 9.0) * (fahr - 32.0);
printf("%3.0f %6.1f\n", fahr, celsius);
fahr += step;
}
return ;
}
//由于输出时占位符使用错误,导致大量的强制转换,从而得出奇怪的结果。
//华氏温度转换为摄氏温度
#include<stdio.h>
int main()
{
float fahr,
celsius,
lower,
upper,
step;
lower = 0.0;
upper = 300.0;
step = 20.0; fahr = lower;
printf("FAHR CELSIUS\n");
while (fahr <= upper) {
celsius = (5.0 / 9.0) * (fahr - 32.0);
printf("%3.0f %6.1f\n", fahr, celsius);
fahr += step;
}
return ;
}
//将摄氏温度转换为华氏温度
#include<stdio.h>
int main()
{
float fahr,
celsius,
lower,
upper,
step; lower = 0.0;
upper = 300.0;
step = 20.0; celsius = lower;
printf("CELSIUS FAHR\n");
while (celsius <= upper) {
fahr = celsius * 9.0 / 5.0 + ;
printf("%3.0f %6.1f\n", celsius, fahr);
celsius += step;
}
//验证表达式getchar() != EOF 的值是0还是1.
#include<stdio.h>
int main()
{
int c; c = getchar() != EOF;
printf("%d\n", c); return ;
}
//本程序用来对字符进行计数
#include<stdio.h>
int main()
{
int count = ;
char c;
while ((c = getchar()) != EOF) {
count++;
}
printf("%d\n", count);
return ;
}
//统计行数
#include<stdio.h>
int main()
{
int nl = ;
char c; while ((c = getchar()) != EOF) {
if (c == '\n')
nl++;
}
printf("%d", nl); return ;
}
//统计行数
#include<stdio.h>
int main()
{
int nl = ;
char c; while ((c = getchar()) != EOF) {
if (c == '\n')
nl++;
}
printf("%d", nl); return ;
//单词计数,此处单词为任何不包含空格,制表符和回退符的字符序列
#include<stdio.h>
#define IN 1
#define OUT 0
int main()
{
int state = OUT,
count = ;
char c;
while ((c = getchar()) != EOF) {
if (c ==' ' || c == '\n' || c == '\t') //当state = OUT且c = 非空时,字符数加一
state = OUT;
else if (state == OUT) {
count++;
state = IN;
}
}
printf("%d", count);
return ;
}

//以逆序的打印华氏温度转换为摄氏温度
#include<stdio.h>
int main()
{
float fahr,
celsius,
lower,
upper,
step; lower = 0.0;
upper = 300.0;
step = 20.0; fahr = upper;
printf("FAHR CELSIUS\n");
while (fahr >= lower) {
celsius = (5.0 / 9.0) * (fahr -);
printf("%3.0f %6.1f\n", fahr, celsius);
fahr -= ;
}
return ;
}
//编写一个打印EOF值的程序
#include<stdio.h>
int main()
{
printf("%d\n", EOF);
return ;
}
//统计空格,制表符,换行符个数的程序。
#include<stdio.h>
int main()
{
int nb = ,
nt = ,
nl = ;
char c; while ((c = getchar()) != EOF) {
if (c == ' ')
nb++;
else if (c == '\t')
nt++;
else if (c == '\n')
nl++;
}
printf("空格符: %d 制表符:%d 换行符:%d\n", nb, nt, nl); return ;
}
//编写一个程序将输入复制到输出的程序,并将其中连续的多个空格用一个空格代替,
#include<stdio.h>
int main()
{
char c, //用来存储此次输入的字符
lastc; //用来记录上次输入的字符 lastc = 'a';
while ((c = getchar()) != EOF) {
if (c != ' ' || lastc != ' ') {
putchar(c);
}
lastc = c;
} return ;
}
//编写一个将输入复制到输出的程序,并将其中的制表符替换为\t,把回退符替换为
//\b,把反斜杠替换为\\. 使其能以可见的方式显示出来
#include<stdio.h>
int main()
{
char c;
while ((c = getch()) != EOF) {
if (c == '\t')
printf("\\t");
else if (c == '\b')
printf("\\b");
else if (c == '\\')
printf("\\\\");
else
putchar(c);
}
return ;
}
//编写一个程序,以每行一个单词的形式打印其输入
#include<stdio.h>
int main()
{
char c,
lastc = 'a';
while((c = getchar()) != EOF) {
if (c != ' ' && c != '\t' && c != '\n')
putchar(c);
else if (lastc != ' ' && lastc != '\t' && lastc != '\n')
putchar('\n');
lastc = c;
}
return ;
}
}

最新文章

  1. 【转】4G内存下MySQL修改配置文件以优化效率(来自discuz)
  2. Web 前沿——HTML5 Form Data 对象的使用
  3. WampServe修改默认网站目录的方法(转)
  4. CSS 中文字体的英文名称
  5. 8个超炫酷的纯CSS3动画及源码分享
  6. Python Tutorial学习(十一)-- Brief Tour of the Standard Library – Part II
  7. Junit简介和常用API
  8. layPage异步分页
  9. 新版live555代理server
  10. android详细信息java.util.ConcurrentModificationException变态
  11. mysql foreign key(外键) 说明与实例
  12. BZOJ 2683: 简单题(CDQ分治 + 树状数组)
  13. JVM学习记录-垃圾收集器
  14. springboot+mysql+mybatis+Mybatis-Generator+druid 项目demo
  15. SQL SERVER的锁机制
  16. CF868 F. Yet Another Minimization Problem 决策单调优化 分治
  17. Delphi StringGrid控件的用法
  18. width多少,超过了用....表示
  19. DES对 json 、http参数加密解密算法
  20. IO异常 的处理 test

热门文章

  1. OC中两个关键字的作用:@property和@synthesize
  2. Unity3D使用mesh创建一个正方形
  3. myeclipse序列号
  4. Linux Mysql 总结
  5. NodeJS爬虫系统初探
  6. Cookies与保持登录(新浪微博的简单模拟登录)
  7. PHP基于变量的引用实现的树状结构
  8. 修改SlidingMenu,使其能够完美运行
  9. Storm csdn
  10. 使用百度语音识别REST API,做全平台语音识别