- 博客(18)
- 收藏
- 关注
原创 C语言程序设计现代方法_第二版,CH14第十四章练习题(Exercises)
CH14_1#include <stdio.h>#define CUBE(x) ((x) * (x) * (x))#define REM(n) ((n) % 4)#define PROD(x, y) ((x) + (y) < 100 ? 1 : 0)int main(void){ int x = 5, y = 100; double a = 5.6, b = 10.2; printf("%f\n", CUBE(a)); printf("%d\
2020-10-25 13:15:54 760 1
原创 C语言程序设计现代方法_第二版,CH13第十三章编程题(Programming_Projects)
CH13_1#include <stdio.h>#include <string.h>int main(void){ char a[20]; char smallest_word[20], largest_word[20]; printf("Enter word: "); scanf("%s", a); strcpy(s...
2020-02-28 19:05:04 2647 5
原创 C语言程序设计现代方法_第二版,CH13第十三章练习题(Exercises)
CH13_1Incorrect calls:(b) printf expects second argument to be of type char to match format specifier %c, second argument received is type char *.(c) printf expects second argument to be of typ...
2020-02-23 17:55:58 2265
原创 C语言程序设计现代方法_第二版,CH12第十二章编程题(Programming_Projects)
CH12_1(a):#include <stdio.h>#define MAX_LEN 100 int main(void){ char a[MAX_LEN]; int i; printf("Enter a message: "); for (i = 0; i < MAX_LEN; i++) { a[i] =...
2020-02-22 15:54:18 1511
原创 C语言程序设计现代方法_第二版,CH12第十二章练习题(Exercises)
CH12_1//(a):14 (b):34 (c):4 (d):true (e):falseCH12_2//不合法原因:指针变量只支持三种运算,因此指针变量low和high不可相加运算;//考虑到指针变量可以和整数进行运算,因此可修改为如下所示:middle = low + (high - low)/2; //合法CH12_3a = {10, 9, 8, 7, 6, 5, 4, ...
2020-02-21 22:44:16 1151
原创 C语言程序设计现代方法_第二版,CH11第十一章编程题(Programming_Projects)
CH11_1void pay_amount(int dollars, int* twenties, int* tens, int* fives, int* ones){ *twenties = dollars / 20; *tens = dollars % 20 / 10; *fives = dollars % 20 % 10 / 5; *ones = dollars % 20 % 1...
2020-02-18 18:06:56 1186 1
原创 缓冲区(Buffer)与缓存(Cache)异同
缓冲区(Buffer)定义缓冲区(Buffer),它是内存空间的一部分。也就是说,在内存空间中预留了一定的存储空间,这些存储空间用来缓冲输入或输出的数据,这部分预留的空间就叫做缓冲区,显然缓冲区是具有一定大小的。有时候,从键盘输入的内容,或者将要输出到显示器上的内容,会暂时进入缓冲区,待时机成熟,再一股脑将缓冲区中的所有内容“倒出”,我们才能看到变量的值被刷新,或者屏幕产生变化。有时候,用户...
2020-02-18 16:42:59 2779
原创 C语言程序设计现代方法_第二版,CH11第十一章练习题(Exercises)
CH11_1// (a)and(g)are right;// 注意对于(h),由于i并非指针变量,因此不可对其做间接寻址操作;CH11_2// 结论:只有(e)(f)(i)是合法的;// 注意两点:// 1.赋值运算符两边的变量类型是否相同?// 比如:(d),p为指向int的指针,而&p为指向 指向int的指针 的指针;// 2.区分左值和右值?// 比如:&...
2020-02-17 22:05:42 2011
原创 C语言程序设计现代方法_第二版,CH10第十章编程题(Programming_Projects)
CH10_1#include <stdio.h>#include <stdbool.h>#include <stdlib.h>#define STACK_SIZE 100char contents[STACK_SIZE];int top = 0;void make_empty(void);int stack_overflow(void);i...
2020-02-17 13:43:26 1070
原创 C语言程序设计现代方法_第二版,CH9第九章编程题(Programming_Projects)
CH9_1#include <stdio.h>void selection_sort(int a[], int n);int main(void){ int a[100] = { 0 }; int i, count = 0; printf("Enter a series integers: "); scanf("%d", &a[0]...
2020-02-15 22:09:36 662
原创 C语言程序设计现代方法_第二版,CH9第九章练习题(Exercises)
CH9_1//两处错误,下为改正后函数:double triangle_area(double base, double height){ double product; product = base * height; return product / 2;}CH9_2int check(int x, int y, int n) { return x ...
2020-02-14 22:29:32 1038 2
原创 C语言程序设计现代方法_第二版,CH8第八章编程题(Programming_Projects)
CH8_1#include <stdio.h>int main(void){ int digit_count[10] = { 0 }; int digit; long long n; printf("Enter a number: "); scanf("%lld", &n); while (n > 0) { ...
2020-02-13 21:10:32 1005
原创 C语言程序设计现代方法_第二版,CH7第七章编程题(Programming_Projects)
CH7_1#include <stdio.h>int main(void){ int n, odd, square; printf("This program prints a table of squares.\n"); printf("Enter number of entries in table: "); scanf("%d", &n); odd ...
2020-02-13 20:05:37 725 2
原创 C语言程序设计现代方法_第二版,CH6第六章编程题(Programming_Projects)
CH6_1#include <stdio.h>int main(void){ double max = 0, n; do { printf("Enter a number:"); scanf("%lf", &n); max = max < n ? n : max; } while (n ...
2020-02-13 18:03:02 798
原创 C语言程序设计现代方法_第二版,CH5第五章编程题(Programming_Projects)
CH5_1#include <stdio.h>int main(void){ int num, a; printf("Enter a number: "); scanf("%d", &num); if (num / 1000 > 0) { a = 4; } else if (num / 100 &...
2020-02-12 22:50:20 594
原创 C语言程序设计现代方法_第二版,CH4第四章编程题(Programming_Projects)
CH4_1#include <stdio.h>int main(void){ int n; printf("Enter a two-digit number: "); scanf("%d", &n); printf("The reversal is: %d%d\n", n % 10, n / 10); return 0;}...
2020-02-12 19:36:46 441
原创 C语言程序设计现代方法_第二版,CH3第三章编程题(Programming_Projects)
CH3_1#include <stdio.h>int main(void){ int month, day, year; printf("Enter a date (mm/dd/yyyy): "); scanf("%d/%d/%d", &month, &day, &year); printf("You entered t...
2020-02-12 17:36:03 361
原创 C语言程序设计现代方法_第二版,CH2第二章编程题(Programming_Projects)
CH2_1#include <stdio.h>int main(void){ printf(" *\n"); printf(" *\n"); printf(" *\n"); printf("* *\n"); printf(" * *\n"); printf(" *\n"); return 0;}CH2_2#inclu...
2020-02-12 17:03:38 200
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人