2019年5月25日
摘要:
8.12.5 include int main(void) { int rangebig, rangesmall, input; int defaultnum = 67; // scanf("%d", &input); while(scanf("%d", &input)) { if (input d
阅读全文
posted @ 2019-05-25 21:24
viviLy
阅读(106)
推荐(0)
2019年5月20日
摘要:
如果有超过2个连续的非字母出现则单词计数不准确。 8.11.4.c include include int main(void) { int word = 0, ch_total = 0, nocharflag = 0; char ch; while ((ch = getchar()) != EOF
阅读全文
posted @ 2019-05-20 23:47
viviLy
阅读(169)
推荐(0)
摘要:
8.11.3.c include include int main(void) { char ch; int upper = 0, lower = 0, total = 0; while ((ch = getchar()) != EOF) { ++total; if (islower(ch) 0)
阅读全文
posted @ 2019-05-20 20:35
viviLy
阅读(175)
推荐(0)
2019年5月14日
摘要:
8.10.8 include int main(void) { printf("使用getchar函数之前记得处理换行符"); putchar('\n'); printf("在使用缓冲输入的系统中,"); printf("把数值和字符混合输入会遇到"); printf("什么潜在问题?"); put
阅读全文
posted @ 2019-05-14 21:45
viviLy
阅读(371)
推荐(0)
2019年5月13日
摘要:
8_8 menuette.c 菜单程序 include char get_choice(void); char get_first(void); int get_int(void); void count(void); int main(void) { int choice; void count(
阅读全文
posted @ 2019-05-13 00:18
viviLy
阅读(162)
推荐(0)
摘要:
// checking.c 输入验证 include include // 验证输入是一个整数 long get_long(void); // 验证范围的上下限是否有效 bool bad_limits(long begin, long end, long low, long high); // 计算
阅读全文
posted @ 2019-05-13 00:17
viviLy
阅读(170)
推荐(0)
2019年5月9日
摘要:
7.12.11 include define artichoke 2.05 define beet 1.15 define carrot 1.09 define discount 0.95 int main(void) { double partichoke, sum_artichoke_pound
阅读全文
posted @ 2019-05-09 17:45
viviLy
阅读(291)
推荐(0)
摘要:
windows 下实现 shutdown_two.c 此为第三版 // 我需要一个断开网络,启用网络,定时发送邮件后关机的功能,其中定时发送邮件功能是邮件客户端完成;原来的工具是用bat实现的,后来给BAT内容放到C中,延时部分用的还是 choice ,因此需要手工输入延时时间。 // 后来想做个自
阅读全文
posted @ 2019-05-09 14:59
viviLy
阅读(582)
推荐(0)
2019年5月7日
摘要:
8.4 guess.c 一个拖沓且错误的猜数字程序 include int main(void) { int guess = 1; printf("Pick an integer from 1 to 100. I will try to guess "); printf("it. \nRespond
阅读全文
posted @ 2019-05-07 23:23
viviLy
阅读(169)
推荐(0)
摘要:
8.3 file_eof.c 打开一个文件并显示该文件 include include // 为了使用exit() int main() { int ch; FILE fp; char fname[50]; // 存储文件名 printf("Enter the name of the file: "
阅读全文
posted @ 2019-05-07 23:22
viviLy
阅读(244)
推荐(0)
摘要:
echo_eof.c 重复输入,直到文件结尾 include int main(void) { int ch; while ((ch = getchar()) != EOF) // Ctrl + Z 结束符 putchar(ch); return 0; }
阅读全文
posted @ 2019-05-07 23:21
viviLy
阅读(263)
推荐(0)
摘要:
8.1 echo.c 重复 输入 include int main(void) { char ch; while ((ch = getchar()) != ' ') putchar(ch); return 0; }
阅读全文
posted @ 2019-05-07 23:21
viviLy
阅读(142)
推荐(0)
2019年5月6日
摘要:
7.12.10 include define big_rate 0.28 define sml_rate 0.15 define single 17850 define god 23900 define mar_two 29750 define mar_one 14875 int main(void
阅读全文
posted @ 2019-05-06 14:19
viviLy
阅读(110)
推荐(0)
2019年5月4日
摘要:
7.12.9 include int main(void) { int num; int i , j; int flag = 0; printf("请输入一个正整数:\n"); if ((scanf("%d", &num) == 1) && (num 0)) { for (j = 3; j
阅读全文
posted @ 2019-05-04 23:00
viviLy
阅读(133)
推荐(0)
2019年4月28日
摘要:
7.12.8 include define over_time 1.5 10 define three_hundred_rate 0.15 define one_hundred_half_rate 0.2 define more_then_four_hun_half_rate 0.25 define
阅读全文
posted @ 2019-04-28 22:59
viviLy
阅读(97)
推荐(0)
2019年4月25日
摘要:
7.12.8 include define over_time 1.5 10 define three_hundred_rate 0.15 define one_hundred_half_rate 0.2 define more_then_four_hun_half_rate 0.25 define
阅读全文
posted @ 2019-04-25 22:27
viviLy
阅读(121)
推荐(0)
2019年4月24日
摘要:
7.12.7 include define basic_wage 10.00 define over_time 1.5 10 define three_hundred_rate 0.15 define one_hundred_half_rate 0.2 define more_then_four_h
阅读全文
posted @ 2019-04-24 21:25
viviLy
阅读(100)
推荐(0)
摘要:
7.12.6 include int main(void) { char ch; char prechar; int frequency = 0; while ((ch = getchar()) != ' ') { if (ch == 'e') prechar = 'e'; if ((ch == '
阅读全文
posted @ 2019-04-24 16:12
viviLy
阅读(82)
推荐(0)
摘要:
7.12.4 include int main(void) { int Exclamationtoperiod = 0; int two2one = 0; char ch; while ((ch = getchar()) != ' ') { switch (ch) { case '.': putch
阅读全文
posted @ 2019-04-24 15:32
viviLy
阅读(100)
推荐(0)
摘要:
7.12.4 include int main(void) { int Exclamationtoperiod = 0; // 感叹号替换句号次数 int two2one = 0; // 两个感叹号替换一个感叹号次数 char ch; while ((ch = getchar()) != ' ')
阅读全文
posted @ 2019-04-24 15:17
viviLy
阅读(98)
推荐(0)
摘要:
7.12.3 include int main(void) { int odd_number = 0; int even_number = 0; int odd_sum = 0; int even_sum = 0; int num; while ( scanf("%d", &num) == 1) {
阅读全文
posted @ 2019-04-24 14:50
viviLy
阅读(112)
推荐(0)
2019年4月23日
摘要:
7.12.2 include int main(void) { char ch; int count = 0; while ((ch = getchar()) != ' ') { printf("%c %d ", ch, ch); if ((++count % 8) == 0) printf("\n
阅读全文
posted @ 2019-04-23 00:16
viviLy
阅读(105)
推荐(0)
2019年4月22日
摘要:
7.12.1 include int main(void) { char ch; int space_count = 0; int linebreak_count = 0; int other_count = 0; while ((ch = getchar()) != ' ') { if (ch =
阅读全文
posted @ 2019-04-22 23:29
viviLy
阅读(117)
推荐(0)
2019年4月21日
摘要:
7.11.8 / retire.c / include int main(void) { int age = 60; while (++age
阅读全文
posted @ 2019-04-21 21:19
viviLy
阅读(95)
推荐(0)
摘要:
左后缀中,当age=64执行完循环体时,到达测试条件age++
阅读全文
posted @ 2019-04-21 20:58
viviLy
阅读(260)
推荐(0)
摘要:
7.11.7 include int main(void) { char ch; int lc = 0; // 统计小写字母 int uc = 0; // 统计大写字母 int oc = 0; // 统计其他字母 while ((ch = getchar()) != ' ') { if (( ch
阅读全文
posted @ 2019-04-21 20:34
viviLy
阅读(116)
推荐(0)
2019年4月16日
摘要:
7.11.5 include int main(void) { int num; for (num = 1; num
阅读全文
posted @ 2019-04-16 23:16
viviLy
阅读(102)
推荐(0)
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
阅读(172)
推荐(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
阅读(131)
推荐(0)
摘要:
7.6.2 break 语句 程序执行到循环中的break语句时,会种植包含它的循环,并继续执行下一阶段。 如果break语句位于嵌套循环内,它只会影响包含它的当前循环。 break还可用于因其他原因退出循环的情况。 在for循环中的break和continue的情况不同,执行完break语句后会直
阅读全文
posted @ 2019-04-13 20:52
viviLy
阅读(162)
推荐(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
阅读(119)
推荐(0)
摘要:
7.6.1 continue 语句 3种循环都可以使用CONTINUE语句。执行到该语句时,会跳过本次迭代的剩余部分,并开始下一轮迭代。如果continue语句在嵌套循环内,则只会影响包含该语句的内层循环。 以上介绍了continue语句让程序跳过循环体的余下部分。那么从何处开始继续循环?对于whi
阅读全文
posted @ 2019-04-13 14:51
viviLy
阅读(196)
推荐(0)
posted @ 2019-04-13 14:07
viviLy
阅读(118)
推荐(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
阅读(218)
推荐(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
阅读(205)
推荐(0)
摘要:
7.5 条件运算符: ?: C提供条件表达式(conditional expression)作为表达if else语句的一种便捷方式,该表达式使用?: 条件运算符。该运算符分为两部分,需要3个运算对象。 条件运算符是C语言中的唯一的三元运算符。 条件表达式的通用形式如下: expression1 ?
阅读全文
posted @ 2019-04-13 12:34
viviLy
阅读(1356)
推荐(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
阅读(269)
推荐(0)
2019年4月10日
摘要:
逻辑运算符的优先级比关系运算符优先级低,所以不必在子表达式两侧加圆括号。 iso646.h头文件 因此,C99标准新增了可代替逻辑运算符的拼写,它们被定义在iso646.h头文件中。 如果在程序中包含该头文件,便可用and代替&&、or代替||、not代替!。 例如,可以把下面的代码: if ( c
阅读全文
posted @ 2019-04-10 22:30
viviLy
阅读(95)
推荐(0)
摘要:
include define PERIOD '.' int main(void) { char ch; int charcount = 0; while ((ch = getchar()) != PERIOD) { if (ch != '"' && ch != '\'') charcount++;
阅读全文
posted @ 2019-04-10 21:55
viviLy
阅读(188)
推荐(0)
2019年4月8日
摘要:
// 7.5 / divisors.c 使用嵌套if语句显示一个数的约数 / \ include <stdio.h> \ include <stdbool.h> int main(void) { unsigned long num; // 待测试的数 unsigned lon
阅读全文
posted @ 2019-04-08 00:08
viviLy
阅读(304)
推荐(0)