2019年4月13日
摘要: 7.12 vowels.c 程序 vowels.c 使用多重标签 include int main(void) { char ch; int a_ct, e_ct, i_ct, o_ct, u_ct; a_ct = e_ct = i_ct = o_ct = u_ct = 0; printf("Ent 阅读全文
posted @ 2019-04-13 21:30 viviLy 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 7.11 animals.c 程序 include include int main(void) { char ch; printf("Give me a letter of the alphabet, and I will give "); printf("an animal name\nbegi 阅读全文
posted @ 2019-04-13 21:06 viviLy 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 7.6.2 break 语句 程序执行到循环中的break语句时,会种植包含它的循环,并继续执行下一阶段。 如果break语句位于嵌套循环内,它只会影响包含它的当前循环。 break还可用于因其他原因退出循环的情况。 在for循环中的break和continue的情况不同,执行完break语句后会直 阅读全文
posted @ 2019-04-13 20:52 viviLy 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 7.10 break.c 程序 include int main(void) { float length, width; printf("Enter the length of the rectangle:\n"); while (scanf("%f", &length) == 1) { prin 阅读全文
posted @ 2019-04-13 20:35 viviLy 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 7.6.1 continue 语句 3种循环都可以使用CONTINUE语句。执行到该语句时,会跳过本次迭代的剩余部分,并开始下一轮迭代。如果continue语句在嵌套循环内,则只会影响包含该语句的内层循环。 以上介绍了continue语句让程序跳过循环体的余下部分。那么从何处开始继续循环?对于whi 阅读全文
posted @ 2019-04-13 14:51 viviLy 阅读(185) 评论(0) 推荐(0) 编辑
摘要: # 阅读全文
posted @ 2019-04-13 14:07 viviLy 阅读(107) 评论(0) 推荐(0) 编辑
摘要: 7.9 skippart.c 程序 include int main(void) { const float MIN = 0.0f; const float MAX = 100.0f; float score; float total = 0.0f; int n = 0; float min = M 阅读全文
posted @ 2019-04-13 14:06 viviLy 阅读(214) 评论(0) 推荐(0) 编辑
摘要: 7.8 paint.c 程序 include define COVERAGE 350 // 每罐尤其可刷的面积(单位:平方英尺) int main(void) { int sq_feet; int cans; printf("Enter number of square feet to be pai 阅读全文
posted @ 2019-04-13 12:42 viviLy 阅读(204) 评论(0) 推荐(0) 编辑
摘要: 7.5 条件运算符: ?: C提供条件表达式(conditional expression)作为表达if else语句的一种便捷方式,该表达式使用?: 条件运算符。该运算符分为两部分,需要3个运算对象。 条件运算符是C语言中的唯一的三元运算符。 条件表达式的通用形式如下: expression1 ? 阅读全文
posted @ 2019-04-13 12:34 viviLy 阅读(1260) 评论(0) 推荐(0) 编辑
摘要: wordcnt.c 程序 include include // 为isspace() 函数提供原型 include // 为bool、true、false提供定义 define STOP '|' int main(void) { char c; // 读入字符 char prev; // 读入的前一 阅读全文
posted @ 2019-04-13 12:31 viviLy 阅读(244) 评论(0) 推荐(0) 编辑