C Primer Plus 第6版 编程练习答案(第九章)

9.1.c #include <stdio.h> double min(double, double); int main(void) { double x, y; printf("Enter two numbers (q to quit): "); while (scanf("%lf %lf", &amp;x, &amp;y) == 2) { printf("The smaller number is %f.\n", min(x,y)); printf("Next two values (q to quit): "); } printf(...
2021-07-24 18:07 | 阅读 1887 次 | 评论 0 条

C Primer Plus 第6版 编程练习答案(第八章)

8.1.c #include <stdio.h> int main(void) { int ch; int ct = 0; while ((ch = getchar()) != EOF) ++ct; printf("%d characters read\n", ct); return 0; } 8.2.c #include <stdio.h> int main(void) { int ch, ct; ct = 0; while((ch = getchar()) != EOF) { if(c...
2021-04-17 23:00 | 阅读 899 次 | 评论 0 条

C Primer Plus 第6版 编程练习答案(第七章)

7.1.c #include <stdio.h> int main(void) { char ch; int sp_ct = 0; int nl_ct = 0; int other = 0; while ((ch = getchar()) != '#') { if (ch == ' ') sp_ct++; else if (ch == '\n') nl_ct++; else other++; } printf("spaces: %d, newlines: %d, others: %d\n", sp_ct,...
2021-04-11 17:07 | 阅读 1090 次 | 评论 0 条

C Primer Plus 第6版 编程练习答案(第六章)

6.1.c #include <stdio.h> int main(void) { char letter[26]; int i; for(i = 0; i < 26; i++) { letter[i] = 'a' + i; printf("%c ", letter[i]); } return 0; } 6.2.c #include <stdio.h> int main(void) { int rows, chars; for(rows = 0; rows < 5; rows++) ...
2021-04-11 12:41 | 阅读 846 次 | 评论 0 条

C Primer Plus 第6版 编程练习答案(第五章)

5.1.c #include <stdio.h> #define PER 60 int main(void) { int minute, second, hour; printf("Please enter minutes.\n"); scanf("%d", &amp;minute); while(minute > 0) { hour = minute / PER; second = minute % PER; printf("%d minutes is %d hours and %d seconds.\n", minute...
2021-04-11 12:38 | 阅读 670 次 | 评论 0 条

C Primer Plus 第6版 编程练习答案(第四章)

4.1.c #include <stdio.h> int main(void) { char first_name[20], last_name[20]; printf("Please enter your first name.\n"); scanf("%s", first_name); printf("Please enter your last name.\n"); scanf("%s", last_name); printf("%s,%s", first_name, last_name); return 0; } ...
2021-04-11 12:35 | 阅读 672 次 | 评论 0 条

C Primer Plus 第6版 编程练习答案(第三章)

3.1.c #include <stdio.h> int main(void) { int int_max = 2147483647 ; printf("%d %d\n",int_max,int_max+1); float float_max = 3.40e38; printf("%f %f\n",float_max,float_max+1); float float_min = 3.40e-38; printf("%f %f\n",float_min,float_min-1); return 0; } ...
2021-04-11 12:31 | 阅读 759 次 | 评论 0 条

C Primer Plus 第6版 编程练习答案(第二章)

2.1.c #include <stdio.h> int main(void) { printf("Gustav Mahler\n"); printf("Gustav\nMahler\n"); printf("Gustav "); printf("Mahler"); return 0; } 2.2.c #include <stdio.h> int main(void) { printf("name: Gustav Mahler\n"); printf("address: China\n")...
2021-04-11 12:25 | 阅读 701 次 | 评论 0 条

C Primer Plus 第6版 编程练习答案(第一章)

1.1.c #include <stdio.h> #define INCH_PER_CM 2.54 int main(void) { double inch, cm; printf("Enter an inch value:"); scanf("%lf", &amp;inch); cm = inch * INCH_PER_CM; printf("The cm value is:%lf\n", cm); return 0; }
2021-04-11 12:21 | 阅读 717 次 | 评论 0 条
浏览9047次
最新评论