博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C primer plus 练习题 第七章
阅读量:7077 次
发布时间:2019-06-28

本文共 1113 字,大约阅读时间需要 3 分钟。

1.

1 #include 
2 3 #define SPACE ' ' 4 #define NEWLINE '\n' 5 6 int main() 7 { 8 int spaces,newlines,others; 9 char ch;10 spaces = newlines = others = 0;11 while((ch=getchar())!= '#')12 {13 /*14 if(ch == SPACE)15 {16 spaces++;17 }else if(ch == NEWLINE)18 {19 newlines++;20 }else21 {22 others++;23 }*/24 switch(ch)25 {26 case SPACE:27 spaces++;28 break;29 case NEWLINE:30 newlines++;31 break;32 default:33 others++;34 break;35 }36 }37 printf("spaces=%d, newlines=%d, others=%d \n", spaces, newlines, others);38 getchar();39 return 0;40 }

 2.

1 #include 
2 3 int main() 4 { 5 int i; 6 char ch; 7 printf("quit input #"); 8 for(i=1; (ch=getchar())!='#'; i++) 9 {10 printf("%c -- %d \t", ch, ch);11 if(i%8 == 0){12 printf("\n");13 }14 }15 getchar();16 return 0;17 }

 

转载地址:http://acpml.baihongyu.com/

你可能感兴趣的文章
转负二进制(个人模版)
查看>>
MySQL数据库如何导入导出
查看>>
yii2: oralce中文,有的汉字是2个字节,有的汉字是3个字节
查看>>
mysql utf8mb4 所引起的问题
查看>>
JGraphT
查看>>
【java】实体类中 按照特定的字段 进行升序/降序 排序
查看>>
Unity Shader 基础(1): RenderType & ReplacementShader
查看>>
51Nod 1016 水仙花数 V2(组合数学,枚举打表法)
查看>>
记一次校招面试
查看>>
DP SRM 661 Div2 Hard: ColorfulLineGraphsDiv2
查看>>
Banner框架
查看>>
php soap实例讲解
查看>>
操作文件夹,删除所有空文件夹
查看>>
Yii1.1应用升级到Yii2.0的一些注意点
查看>>
dede使用方法----调用导航
查看>>
最低位 【杭电-HDOJ-1196】 附题
查看>>
结构化方法、面向对象方法的区别
查看>>
算法笔记_192:历届试题 买不到的数目(Java)
查看>>
WebViewJavascriptBridge-Obj-C和JavaScript互通消息的桥梁
查看>>
linux启动基本流程
查看>>