C Prime Plus编程练习(第十章)

C prime plus 第六版 课后编程练习 第6章 电子版C primer plus 第6版 中文文字版下载地址 https://blog.csdn.net/gouqi426/article/details/106412212 以下为课后练习。 使用编译器 vs 2013 。 如使用其他编译器,可将scanf_s()修改为scanf(),同时删除sizeof()。具体原因请学习scanf_s()和scanf()的区别。 6.16.1编写一个程序,创建一个包含26个元素的数组,并在其中储存26个小写字母。然后打印数组的所有内容。 // 6.16.1 26元素数 阅读详情

1. 修改程序清单10.7的rain.c程序,用指针进行计算(仍然要声明并初始化数组)

/*
 * rain.c
 * 计算每年的总降水量、年平均降水量和5年中每月的平均降水量
 */
#include <stdio.h>

#define MONTHS 12
#define YEARS 5

const float rain[YEARS][MONTHS] = { { 4.3, 4.3, 4.3, 3.0, 2.0, 1.2, 0.2, 0.2,
		0.4, 2.4, 3.5, 6.6 }, { 8.5, 8.2, 1.2, 1.6, 2.4, 0.0, 5.2, 0.9, 0.3,
		0.9, 1.4, 7.3 }, { 9.1, 8.5, 6.7, 4.3, 2.1, 0.8, 0.2, 0.2, 1.1, 2.3,
		6.1, 8.4 },
		{ 7.2, 9.9, 8.4, 3.3, 1.2, 0.8, 0.4, 0.0, 0.6, 1.7, 4.3, 6.2 }, { 7.6,
				5.6, 3.8, 2.8, 3.8, 0.2, 0.0, 0.0, 0.0, 1.3, 2.6, 5.2 } };

void _1(void);
void _2(void);

int main(void) {
	_1();
	_2();
	return 0;
}

void _1(void) {
	int year, month;
	float subtot, total;

	printf("  YEAR     RAINFAIL  (inches)\n");
	for (year = 0, total = 0; year < YEARS; year++) {
		for (month = 0, subtot = 0; month < MONTHS; month++) {
			subtot += rain[year][month];
		}
		printf("%6d %15.1f\n", 2010 + year, subtot);
		total += subtot;
	}
	printf("\nThe yearly average is %.1f inches.\n\n", total / YEARS);
	printf("MONTHLY AVERAGES : \n\n");
	printf("  Jan   Fab   Mar   Apr   May   Jun   Jul   Aug   Sep   Oct   Nov   Dec\n");
	for (month = 0; month < MONTHS; month++) {
		for (year = 0, subtot = 0; year < YEARS; year++) {
			subtot += rain[year][month];
		}
		printf("%5.1f ", subtot / YEARS);
	}
}

void _2(void) {
	int year, month;
	float total, subtot;
	printf("\n\n  YEAR     RAINFAIL  (inches)\n");
	for (year = 0, total = 0; year < YEARS; year++) {
		for (month = 0, subtot = 0; month < MONTHS; month++) {
			subtot += *(*(rain + year) + month);
		}
		printf("%6d %15.1f\n", 2010 + year, subtot);
		total += subtot;
	}
	printf("\nThe yearly average is %.1f inches.\n\n", total / YEARS);
	printf("MONTHLY AVERAGES : \n\n");
	printf("  Jan   Fab   Mar   Apr   May   Jun   Jul   Aug   Sep   Oct   Nov   Dec\n");
	for (month = 0; month < MONTHS; month++) {
		for (year = 0, subtot = 0; year < YEARS; year++) {
			subtot += *(*(rain + year) + month);
		}
		printf("%5.1f ", subtot / YEARS);
	}
}

2.编写一个程序,初始化一个double类型的数组,然后把该数组的内容拷贝至3个其他数组中(在main()中生命者4个数组)。使用带数组表示法的函数进行第1份拷贝。使用带指针表示法和指针递增的函数进行第2份拷贝。把目标数组名、源数组名和带靠背的元素个数作为前两个函数的参数。第3个函数以目标数组名、源数组名和指向源数组最后一个元素后面的元素的指针。也就是说,给定一下声明,则函数调用如下所示:

double source[5] = {1.1, 2.2, 3.3, 4.4, 5.5};
double target1[5];
double target2[5];
double target3[5];
copy_arr(target1, source, 5);
copy_ptr(target2, source, 5);
copy_ptrs(target3, source, source + 5);

#include <stdio.h>

#define ARR_LEN 5

void copy_arr(double [], double [], int);
void copy_ptr(double [], double [], int);
void copy_ptrs(double [], double [], int *);

int main(void) {
	double source[ARR_LEN] = {1.1, 2.2, 3.3, 4.4, 5.5};
	double target1[ARR_LEN], target2[ARR_LEN], target3[ARR_LEN];

	double source[ARR_LEN] = {1.1, 2.2, 3.3, 4.4, 5.5};
	double target1[ARR_LEN];
	double target2[ARR_LEN];
	double target3[ARR_LEN];
	copy_arr(target1, source, ARR_LEN);
	copy_ptr(target2, source, ARR_LEN);
	copy_ptrs(target3, source, source + ARR_LEN);
	return 0;
}

void copy_arr(double target[], double source[], int length) {
	int index;
	for(index = 0; index < length; index++) {
		target[index] = source[index];
		printf("   target[%d] = %5.1f", index, target[index]);
	}
	printf("\n");
}

void copy_ptr(double target[], double source[], int length) {
	target = source;
	int index;
	for(index = 0; index < length; index++){
		printf("   target[%d] = %5.1f", index, *(target + index));
	}
	printf("\n");
}

void copy_ptrs(double target[], double source[], int *ptr) {
	for(target = source; target < ptr; target++){
		printf("   target[%d] = %5.1f", (target - source), *target);
	}
	printf("\n");
}

3.编写一个函数,返回储存在int类型数组中的最大值,并在一个简单的程序中测试该函数

#include <stdio.h>

int largestNumberForArr(int [], int);
int largestNumberForPtr(int *, int);

int main(void) {
	int source[] = {3, 4, 5, 8, 0, 1, 7, 9, 2, 6};
	largestNumberForArr(source, sizeof(source) / sizeof(source[0]));
	largestNumberForPtr(source, sizeof(source) / sizeof(source[0]));
	return 0;
}

int largestNumberForArr(int source[], int length){
	if(length < 1) {
		printf("Your Number Array is Null! Return -1!");
		return -1;
	} else if(length == 1) {
		return source[0];
	}
	int index;
	int largestNumber = source[0];
	for(index = 1; index < length; index++) {
		if(source[index] > largestNumber) {
			largestNumber = source[index];
		}
	}
	printf("Calculator The Largest Number By Array Is %d\n", largestNumber);
	return largestNumber;
}

int largestNumberForPtr(int *source, int length) {
	if(length < 1) {
		printf("Your Number Array is Null! Return -1!");
		return -1;
	} else if(length == 1) {
		return *source;
	}
	int index;
	int lm = *source;
	for(index = 1; index < length; index++) {
		if(*(source + index) > lm) {
			lm = *(source + index);
		}
	}
	printf("Calculator The Largest Number By Pointer Is %d\n", lm);
	return lm;
}

注:如下的这种方式会出现错误

int largestNumberForError(int source[]) {
	int length = sizeof(source) / sizeof(int);
	if(length < 1) {
		printf("Your Number Array is Null! Return -1!");
		return -1;
	} else if(length == 1) {
		return source[0];
	}
	int index;
	int largestNumber = source[0];
	for(index = 1; index < length; index++) {
		if(source[index] > largestNumber) {
			largestNumber = source[index];
		}
	}
}

得到的最终结果是返回source[0],原因是,这个方法中的source数组和main函数中的source数组不一样(可以通过打印数组地址来确认),这个函数中的source数组,无法指定长度,定义的是一个指向int型数组的指针,因此,sizeof(source)返回的就是int类型的字节数,因此sizeof(source) / sizeof(int)始终会返回1.

4. 编写一个函数,返回储存在double类型数组中最大值的下标,并在一个简单的程序中测试该函数

#include <stdio.h>

int getLargestIndexForDoubleArray(double [], int);
int getLargestIndexForDoublePointer(double *, int);

int main() {
	double source[] = {1.1, 2.3, 4.3, 0.1, 3.7, 8.5, 9.2, 2.2, 3.4};
	getLargestIndexForDoubleArray(source, sizeof(source) / sizeof(double));
	getLargestIndexForDoublePointer(source, sizeof(source) / sizeof(double));
	return 0;
}

int getLargestIndexForDoubleArray(double source[], int length) {
	if(length < 1) {
		printf("Your Double Array Is Null!Return -1!");
		return -1;
	} else if(length == 1){
		printf("Your Double Array Just Have One Params!");
		return 0;
	}
	int i, index = 0;
	double largest = source[0];
	for(i = 1; i < length; i++) {
		if(largest < source[i]) {
			largest = source[i];
			index = i;
		}
	}
	printf("The %dth One Is The Largest One!\n", index + 1);
	return index;
}

int getLargestIndexForDoublePointer(double *source, int length) {
	if(length < 1) {
		printf("Your Double Array Is Null!Return -1!");
		return -1;
	} else if(length == 1){
		printf("Your Double Array Just Have One Params!");
		return 0;
	}
	int i, index = 0;
	double largest = *source;
	for( i = 1; i < length; i++) {
		if(largest < *(source + i)) {
			largest = *(source + i);
			index = i;
		}
	}
	printf("The %dth One Is The Largest One!\n", index + 1);
	return index;
}

5. 编写一个函数,返回储存在double类型数组中最大值和最小值的差值,并在一个简单的程序中测试该函数

#include <stdio.h>

double dividerByLargestAndLeast(double [], int);

int main(){
	double source[] = {1.1, 2.3, 4.3, 0.1, 3.7, 8.5, 9.2, 2.2, 3.4};
	dividerByLargestAndLeast(source, sizeof(source) / sizeof(double));
	return 0;
}

double dividerByLargestAndLeast(double source[], int length) {
	if(length < 1) {
		printf("Your Double Array Is Null!Return -1!");
		return -1;
	} else if(length == 1){
		printf("Your Double Array Just Have One Params!");
		return 0;
	}
	double largest = source[0], least = source[0];
	int index;
	for(index = 1; index < length; index++) {
		if(source[index] > largest) {
			largest = source[index];
		}
		if(least > source[index]){
			least = source[index];
		}
	}
	printf("the diminition of maxiuim and miniuim is %f\n", (largest - least));
	return (largest - least);
}

6. 编写一个函数,把double类型数组中的数据倒序排列,并在一个简单的程序中测试该函数

#include <stdio.h>

void sort(double [], int);
void printPositive(double [], int);

int main(){
	double source[] = {1.1, 2.3, 4.3, 0.1, 3.7, 8.5, 9.2, 2.2, 3.4, 7.3};
	printPositive(source, sizeof(source) / sizeof(double));
	sort(source, sizeof(source) / sizeof(double));
	printPositive(source, sizeof(source) / sizeof(double));
	return 0;
}

void printPositive(double * source, int length) {
	int index;
	for(index = 0; index < length; index++) {
		printf("   %.1f   ", *(source + index));
	}
	printf("\n");
}

void sort(double *source, int length) {
	int index;
	for(index = 0; index < length / 2; index++){
		double temp;
		temp = *(source + index);
		*(source + index) = *(source + length - 1 - index);
		*(source + length - 1 - index) = temp;
	}
}

7. 编写一个程序,初始化一个double类型的二维数组,使用编程练习2中的一个拷贝函数把该数组中的数据拷贝至另一个二维数组中(因为二维数组是数组的数组,所以可以使用处理一位数组的拷贝函数来处理数组中的每个子数组)

#include <stdio.h>

#define WIDTH 5
#define HEIGHT 5

void copy_arr(double [], double [], int);
void print_arr(int, int, double [*][*]);
void copy_ptr(double *, double *, int);
void print_ptr(int, int height, double (*)[height]);

int main(void) {
	double source[WIDTH][HEIGHT] = {
			{ 1.1, 2.2, 3.3, 5.2, 4.3},
			{ 4.4, 5.5, 6.6, 4.2, 2.4},
			{ 7.7, 8.8, 9.9, 5.4, 3.2},
			{ 1.4, 4.2, 1.3, 1.2, 4.0},
			{ 1.2, 7.2, 9.3, 0.2, 4.8}
	};
	double target[WIDTH][HEIGHT];
	int index;
	for(index = 0; index < WIDTH; index++) {
		copy_arr(target[index], source[index], HEIGHT);
	}
	print_arr(WIDTH, HEIGHT, target);

	for(index = 0; index < WIDTH; index++) {
		copy_ptr(target[index], source[index], HEIGHT);
	}
	print_ptr(WIDTH, HEIGHT, target);
	return 0;
}

void copy_arr(double target[], double source[], int length) {
	int index;
	for(index = 0; index < length; index++) {
		target[index] = source[index];
	}
}

void print_arr(int width, int height, double target[width][height]) {
	int w, h;
	for(w = 0; w < width; w++) {
		for(h = 0; h < height; h++) {
			printf("target[%d][%d] = %5.1f\n", w, h, target[w][h]);
		}
	}
	printf("\n");
}

void copy_ptr(double *target, double *source, int length) {
	int index;
	for(index = 0; index < length; index++) {
		*(target + index) = *(source + index);
	}
}

void print_ptr(int width, int height, double (*target)[height]) {
	int w, h;
	for(w = 0; w < width; w++) {
		for(h = 0; h < height; h++) {
			printf("target[%d][%d] = %5.1f\n", w, h, *(*(target + w) + h));
		}
	}
	printf("\n");
}

注:这个问题卡了好久,主要的问题是,定义使用指针函数copy_ptr和print_ptr函数,之前的写法是

copy_ptr(double **target, int width, int height);
print_ptr(double **target, int width, int height);

这种写法是错误的,从网上找的一些资料,然后结合自己的思考得出问题出现的原因为:

定义函数的时候,target为重新定义的二维数组,而定义二维数组的时候,一定要指定其第二个位数,即本例子中的每一行包含的元素个数,而上述错误写法中,并未指定行和列,因此,产生错误

另由于需要定义函数为通用类型,因此需要使用变长数组来处理本例,因此得出如上正确的写法

8.使用编程练习2中的拷贝函数,,把一个内含7个元素的数组中的第3~第5个元素拷贝至内含3个元素的数组中。该函数本身不需要修改,只需要选择合适的实际参数(实际参数不需要是数组名和数组大小,只需要是数组元素的地址和待处理元素的个数)

#include <stdio.h>

#define SOURCE_LENGTH 7
#define TARGET_LENGTH 3

void copy_ptr(double *, double *, int);
void print_ptr(int , double *);

int main(void) {
	double source[SOURCE_LENGTH] = {1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7};
	double target[TARGET_LENGTH];
	copy_ptr(target, source + 3, TARGET_LENGTH);
	print_ptr(TARGET_LENGTH, target);
	return 0;
}

void copy_ptr(double *target, double *source, int length) {
	int index;
	for(index = 0; index < length; index++) {
		*(target + index) = *(source + index);
	}
}

void print_ptr(int length, double target[]) {
	int index;
	for(index = 0; index < length; index++) {
		printf("target[%d] = %5.1f\n", index, *(target + index));
	}
}

9.编写一个程序,初始化一个double类型的3x5二维数组,使用一个处理变长数组的函数将其拷贝至另一个二维数组中。还要编写一个以变长数组为形参的函数以显示两个数组的内容,这两个函数应该能处理任一N x M数组(如果编译器不支持变长数组,就是用传统C函数处理Nx5的数组)

#include <stdio.h>

#define WIDTH 3
#define HEIGHT 5

void copy_arr(int, int, double[*][*], double[*][*]);
void print_arr(int, int, double[*][*], double[*][*]);
void copy_ptr(int, int height, double (*)[height], double (*)[height]);
void print_ptr(int, int height, double (*)[height], double (*)[height]);

int main() {
	double source[WIDTH][HEIGHT] = {
			{ 1.1, 3.2, 4.3, 5.4, 6.5 },
			{ 3.1, 4.2, 5.3, 6.4, 7.5 },
			{ 4.1, 5.2, 6.3, 7.4, 8.5 }
	};
	double target[WIDTH][HEIGHT];
	double target2[WIDTH][HEIGHT];
	copy_arr(WIDTH, HEIGHT, target, source);
	print_arr(WIDTH, HEIGHT, target, source);
	copy_ptr(WIDTH, HEIGHT, target2, source);
	print_ptr(WIDTH, HEIGHT, target2, source);
	return 0;
}

void copy_arr(int width, int height, double target[width][height],
		double source[width][height]) {
	int w, h;
	for (w = 0; w < width; w++) {
		for (h = 0; h < height; h++) {
			target[w][h] = source[w][h];
		}
	}
}

void print_arr(int width, int height, double target[width][height],
		double source[width][height]) {
	int w, h;
	for (w = 0; w < width; w++) {
		for (h = 0; h < height; h++) {
			printf("target[%d][%d] = %5.1f\t\tsource[%d][%d] = %5.1f\n", w, h,
					target[w][h], w, h, source[w][h]);
		}
	}
	printf("\n");
}

void copy_ptr(int width, int height, double (*target)[height], double (*source)[height]) {
	int w, h;
	for (w = 0; w < width; w++) {
		for (h = 0; h < height; h++) {
			*(*(target + w) + h) = *(*(source + w) + h);
		}
	}
}

void print_ptr(int width, int height, double (*target)[height], double (*source)[height]) {
	int w, h;
	for (w = 0; w < width; w++) {
		for (h = 0; h < height; h++) {
			printf("target[%d][%d] = %5.1f\t\tsource[%d][%d] = %5.1f\n", w, h, *(*(target + w) + h), w, h, *(*(source + w) + h));
		}
	}
	printf("\n");
}

10.编写一个函数,把两个数组中相对应的元素相加,然后把结果储存到第3个数组中。也就是说,如果数组1中包含的值是2、4、5、8,数组2中包含的值是1、0、4、6,那么该函数把3、4、9、14赋给第3个数组。函数接收3个数组名和一个数组大小。在一个简单的程序中测试该函数

#include <stdio.h>

#define LENGTH 5

void sumArr(int [], int [], int [], int);
void sumArrForPtr(int *, int *, int *, int);

int main(void) {
	int source1[LENGTH] = {1, 2, 3, 4, 5};
	int source2[LENGTH] = {5, 6, 7, 8, 9};
	int target1[LENGTH];
	int target2[LENGTH];
	sumArr(source1, source2, target1, LENGTH);
	sumArrForPtr(source1, source2, target2, LENGTH);
	return 0;
}

void sumArr(int source1[], int source2[], int target[], int length) {
	int index;
	for(index = 0; index < length; index++) {
		target[index] = source1[index] + source2[index];
		printf("target[%d] = %d \n", index, target[index]);
	}
	printf("\n");
}

void sumArrForPtr(int *source1, int *source2, int *target, int length) {
	int index;
	for(index = 0; index < length; index++) {
		*(target + index) = *(source1 + index) + *(source2 + index);
		printf("*(target + %d) = %d\n", index, *(target + index));
	}
	printf("\n");
}

11.编写一个程序,声明一个int类型的3x5二维数组,并用合适的值初始化它。该程序打印数组中的值,然后各值翻倍(即是原值的2倍),并显示出各元素的新值。编写一个函数显示数组的内容,再编写一个函数把各元素的值翻倍。这两个函数都以函数名和行数作为参数。


#include <stdio.h>

#define WIDTH 3
#define HEIGHT 5

void print_arr(int, int, int [*][*]);
void print_twice_arr(int, int, int [*][*]);
void print_ptr(int, int height, int (*)[height]);
void print_twice_ptr(int, int height, int (*)[height]);

int main(void) {
	int source[WIDTH][HEIGHT] = {
			{3, 1, 4, 5, 7},
			{2, 3, 4, 1, 7},
			{5, 8, 0, 2, 6}
	};
	print_arr(WIDTH, HEIGHT, source);
	print_twice_arr(WIDTH, HEIGHT, source);
	print_ptr(WIDTH, HEIGHT, source);
	print_twice_ptr(WIDTH, HEIGHT, source);
	return 0;
}

void print_arr(int width, int height, int source[width][height]) {
	int w, h;
	for(w = 0; w < width; w++) {
		for(h = 0; h < height; h++){
			printf("source[%d][%d] = %d\n", w, h, source[w][h]);
		}
	}
	printf("\n");
}

void print_twice_arr(int width, int height, int source[width][height]) {
	int w, h;
	for(w = 0; w < width; w++) {
		for(h = 0; h < height; h++){
			printf("source[%d][%d] = %d\n", w, h, source[w][h] * 2);
		}
	}
	printf("\n");
}

void print_ptr(int width, int height, int (*source)[height]) {
	int w, h;
	for(w = 0; w < width; w++) {
		for(h = 0; h < height; h++){
			printf("source[%d][%d] = %d\n", w, h, *(*(source + w) + h));
		}
	}
	printf("\n");
}

void print_twice_ptr(int width, int height, int (*source)[height]) {
	int w, h;
	for(w = 0; w < width; w++) {
		for(h = 0; h < height; h++){
			printf("source[%d][%d] = %d\n", w, h, (*(*(source + w) + h)) * 2);
		}
	}
	printf("\n");
}

12.重写程序清单10.7的rain.c程序,把main()中的主要任务都改成用函数来完成

参见第1题

13.编写一个程序,提示用户输入3组数,每组数包含5个double类型的数(假设用户都正确地响应,不会输入非数值数据)。该程序应完成下列任务

a.把用户输入的数据储存在3x5的数组中

b.计算每组(5个)数据的平均值

c.计算所有数据的平均值

d.找出这15个数据中的最大值

e.打印结果

每个任务都要用单独的函数来完成(使用传统C处理数组的方式)。完成任务b,要编写一个计算并返回一维数组平均值的函数,利用循环调用该函数3次。对于处理其他任务的函数,应该把整个数组作为参数,完成任务c和d的函数应把结果返回主调函数。

#include <stdio.h>

#define WIDTH 3
#define HEIGHT 5

void scanf_arr(double target[], int height);
double average_line(double target[], int length);
double average_all(int width, int height, double target[width][height]);
int max_all(int width, int height, double target[width][height]);
void print_arr(int width, int height, double target[width][height]);

int main(void) {
	double target[WIDTH][HEIGHT];
	int width;
	for(width = 0; width < WIDTH; width++) {
		scanf_arr(target[width], HEIGHT);
	}
	int index;
	double average;
	for(index = 0;index < WIDTH; index++) {
		average = average_line(target[index], HEIGHT);
		printf("The Average Of Line %d is %5.1f\n", index, average);
	}
	average = average_all(WIDTH, HEIGHT, target);
	printf("The Average Of All Array is %5.1f\n", average);
	max_all(WIDTH, HEIGHT, target);
	print_arr(WIDTH, HEIGHT, target);

}

void scanf_arr(double target[], int height) {
	int index;
	printf("Please Input 5 Double Numbers:\n");
	for(index = 0; index < height; index++){
		scanf("%lf", &target[index]);
	}
}

double average_line(double target[], int length) {
	int index;
	double sum, average;
	for(index = 0; index < length; index++){
		sum += target[index];
	}
	average = sum / length;
	return average;
}

double average_all(int width, int height, double target[width][height]) {
	int w, h;
	double sum, average;
	for(w = 0; w < width; w++) {
		for(h = 0; h < height; h++) {
			sum += target[w][h];
		}
	}
	average = sum / (width * height);
	return average;
}

int max_all(int width, int height, double target[width][height]) {
	int w, h;
	double maxNumber;
	int indexWidth = 0, indexHeight = 0;
	maxNumber = target[0][0];
	for(w = 0; w < width; w++) {
		for(h = 0; h < height; h++) {
			if(maxNumber < target[w][h]) {
				maxNumber = target[w][h];
				indexWidth = w;
				indexHeight = h;
			}
		}
	}
	printf("The Max Number of This Array is target[%d][%d] = %5.1f\n", indexWidth, indexHeight, maxNumber);
	return maxNumber;
}

void print_arr(int width, int height, double target[width][height]) {
	int w, h;
	for(w = 0; w < width; w++) {
		for(h = 0; h < height; h++) {
			printf("   target[%d][%d] = %5.1f", w, h, target[w][h]);
		}
		printf("\n");
	}
	printf("\n");
}

14.以变长数组作为函数形参,完成编程练习13

参见13题

USB设备识别码VID和PID详解:如何查询和自定义你的设备ID 本文详细解析了USB设备识别码VID和PID的核心作用、查询方法及自定义配置技巧。VID(供应商识别码)和PID(产品识别码)是USB设备的唯一身份证,用于驱动匹配和功能识别。文章提供了Windows和Linux系统下的查询方法,并探讨了如何合法获取和自定义VID/PID,适合硬件开发者和DIY爱好者参考。 阅读详情

相关推荐

Cesium实战:从DEM数据到3D地形可视化的全流程解析

本文详细解析了从DEM数据到3D地形可视化的全流程,重点介绍了Cesium和Cesiumlab在数字高程模型(DEM)处理与地形数据转换中的应用。通过实战案例和工具对比,帮助开发者高效实现地形可视化,并分享性能优化与高级功能开发经验。

weixin_29079743的博客 339

C语言程序设计—假设银行一年整存零取的月息为1.875%(年息为12乘1.875%,年息按复利计算),现在某人手头有一笔钱,他打算在今后5年中,每年年底取出1000元作为娃来年的教育金

假设银行一年整存零取的月息为1.875%(年息为12*1.875%,年息按复利计算),现在某人手头有一笔钱,他打算在今后5年中,每年年底取出1000元作为孩子来年的教育金,到第5年孩子毕业时刚好取完这笔钱,请采用逆推法编程计算第1年年初时他应存入银行多少钱。 **输出格式要求:"He must save %.2f at the first year.\n" 程序运行示例如下: He must save 2833.29 at the first year. #include <stdio.h&g

WZY22502701的博客 2868

delphi android发送与接收广播

在发送广播时,使用`SendBroadcast`函数,并传入广播的Action。在接收广播时,创建一个继承自`TAndroidBroadcastReceiver`的类,并在`onReceive`方法中处理接收到的广播。然后,使用`RegisterBroadcastReceiver`函数注册广播接收器,并在`UnregisterBroadcastReceiver`函数中取消注册。请注意替换示例代码中的`YOUR_ACTION`为实际的广播Action。// 处理接收到的广播。

GuoGuoABC 1215

记录:C语言初学者阅读《C Primer Plus》的经验总结

C语言入门推荐书籍

半汀烟雨·碎菁寒 3万+

Kubernetes集群资源优化实战:Volcano调度器如何帮你省下30%GPU算力

本文详细介绍了如何通过Volcano调度器的Binpack策略优化Kubernetes集群中的GPU资源利用率,解决AI模型训练中的资源碎片化问题。通过实战配置和调优指南,帮助用户提升30%的GPU算力利用率,显著降低任务等待时间和硬件成本。

weixin_30832143的博客 509

MinerU安装指南:从源码到验证的完整流程

本文详细介绍了MinerU文档转换工具的安装流程,从源码获取、依赖安装到验证步骤,提供了完整的安装指南和常见问题解决方案。特别适合技术写作者和开发者快速部署这款高效的文档转换工具,提升工作效率。

weixin_29243279的博客 551

数据和C——万字详解(C Primer Plus)

程序离不开数据。把数据、字母和文字输入计算机,就是希望它利用这些数据完成某些任务。例如,需要计算一份利息或显示一份葡萄酒商的排序列表。本篇文章除了介绍如何读取数据外,还将教会读者如何操控数据。C语言提供了两大系列的多种数据类型。本篇文章将详细介绍两大数据类型:整数类型和浮点数类型,详细介绍这些数据类型是什么、如何声明它们、如何及何时使用它们。除此之外,还将介绍变量和常量的区别。

Zhenyu_Coder的博客 1953

基于ADS\HFSS\Matlab的平面带通发夹滤波器设计

写在最前面,前段时间完成了一个小项目,实现13.5~14GHz的带通滤波器,算是第一个微波项目,在老师、学长、各种大神的指点下,最终完成了指标,想来这段时间收获良多,想到老师教导的,有能力的话要尽可能帮助别人,以及网络上很少面向于小白的教程,于是决定把自己做这个小项目的经过,一些关键步骤,还有软件操作和公式讲解都发出来,供大家指正借鉴。由于我目前大三,刚学习电磁场、微波工程等等,技术实在有限,同时这样是我第一次发帖子,只能尽可能的将自己确认过正确的内容,步骤以及一些经验写出来,供大家借鉴。

likaifeng12138的博客 5238

《C Primer Plus》(第6版)

《C Primer Plus》(第6版)

ProgramNovice的博客 1万+

使用再生龙还原镜像文件到硬盘

1. 把制作好的再生龙光盘插入需要的电脑,开机按F4使用再生龙启动2. 选择默认的:Clonezailla live(Default settings,VGA 800*600),然后等待几分钟 3. 选择语言:简体中文 4. 选择不修改键盘映射 5. 选择使用再生龙          6. 选择硬盘/分区(存到/来自)镜像文件,此选项既可以制作镜像,也可以恢复镜像。 7. 使用本机的分区     ...

weixin_42168893的博客 1万+

NX二次开发新建组件

NXOpen新建组件

qq_39541524的博客 333

初识C语言 ——“C Primer Plus”

初识C语言噢

weixin_74957752的博客 4735

华为OD机试真题 新系统 - 计算数列位置N的值 (Java/Py/C/C++/Js/Go)

本文整理华为 OD 机试新系统机考真题库,涵盖高频考点精析与完整题目内容,提供 C 语言、Java、C++、Python、Go、JavaScript 多语言源码实现,搭配详细解题思路讲解,并支持在线 OJ 刷题练习,助力高效备考华为 OD 机试新系统。

算法大师! 2034

C prime plus 第十章 编程练习答案

拖更严重,但还是祝大家新春快乐~情人节快乐! /* 10-1.c -- 修改程序清单10.7的rain.c程序,用指针进行计算(仍然要声明并初始化数组)*/ #include<stdio.h> #define MONTHS 12 #define YEARS 5 int main(void) { // 用2010~2014年的降水量数据初始化数组 const float rain[YEARS][MONTHS] = { { 4.3, 4.3, 4.3, 3.0, 2.0, 1.2, 0

Zach1Lavine的博客 479

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

C Prime Plus中文第六版编程题——第十章练习

1.修改程序清单10.7的rain.c程序,用指针进行计算(仍然要声明并初始 化数组)。 #include <stdio.h> #include <stdlib.h> #define MONTHS 12 #define YEARS 5 int main() { const float rain[YEARS][MONTHS]={ {4.3, 4.3, ...

kasalala的博客 781

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

C primer plus第10章编程练习答案

编程练习答案是我学习过程中所敲,作为一个学渣,答案是以完成习题和易理解为导向,很少有一些五彩缤纷的算法。程序仅作为交流,如有错误与不足还请指出。 所用软件:VS2019 答案中没有第9题和第14题,原因是编译器不支持变长数组。 10.10.1 /* rain.c -- 计算每年的总降水量、年平均降水量和5年中每月的平均降水量 */ //subtot += rain[year][month];改为subtot += *(*(rain + year) + month); #include <stdio.

qq_36536630的博客 695

c primer plus 第六版 第十章编程练习

(编译环境 Microsoft Visual Studio 2019) (变长数组的题用MinGW的gcc编译) 1. /*1.*/ #include<stdio.h> #define MONTHS 12 #define YEARS 5 int main(void) { const float rain[YEARS][MONTHS] = { {4....

lnjoy 1145

《C Primer Plus》第六版第十章课后题

#include &amp;amp;amp;amp;lt;stdio.h&amp;amp;amp;amp;gt; #if 0 /* 7-1 */ void main(void) { int space_count = 0; int n_count = 0; int other_count = 0; char ch; printf(&amp;amp;amp;quot;Please enter the string:\n&amp;amp;amp;q

短腿酱的博客 407

《C++prime plus》第五版编程练习答案

【代码】《C++prime plus》第五版编程练习答案。

Black33的博客 1465

C Prime Plus 第6章习题

P170~P176

weixin_45641816的博客 1080

C++prime plus 第十章课后编程练习

@C++prime plus 第十章编程练习(用两种数据形式描述数据成员) 为复习题5描述的类提供方法定义,并编写一个小程序来演示所有特性。 复习题5:定义一个类来表示银行账户。数据成员包括储户姓名、账号(使用字符串)和存款。成员函数执行如下操作 ~创建一个对象并将其初始化; ~显示储户姓名、账号和存款; ~存入参数指定的存款; ~取出参数指定的存款。 ~使用字符串和字符数组两种数据形式描述数据成...

weixin_44735475的博客 1168

C Primer Plus第十一章编程练习

说一些题外话,只是做这些简单的章节后的编程练习,就用了这么长的时间,可以说当时在学校的时候,天天做实验,写实验报告,还要兼顾好几门课。需要对本题说明的是,题目要求是十个字符串组成的字符串列表,但是我在测试程序的时候一直用的是3个,因为好输入,也好看要求的格式实现了吗,所以如果你想看一下十个的话,或者想试一下EOF的话,就自行试一下吧,反正我去比较的时候也不是按照行数去比较的,是按照当前程序输入了多少行字符串,理论上不会对程序有影响,如果后续还有问题的话,欢迎私信哦。接下来,来看一下第九题的要求。

qq_49674227的博客 1403

整理:C Primer Plus 编程练习

C Primer Plus 第6版 编程练习 整理至第10章

一只大鸽子的博客 2007

《C Primer Plus》编程练习—第11章

第11章练习

chaofeng426的博客 726

C和C++ Prime Plus 学习资源:一站式编程学习解决方案

C和C++ Prime Plus 学习资源:一站式编程学习解决方案 去发现同类优质开源项目:https://gitcode.com/ 项目介绍 在编程学习的道路上,找到一套合适的学习资源至关重要。C和C++ Prime Plus 学习资源为您提供了一套全面的编程学习解决方案,涵盖C语言和C++语言的基础到高级知识。项目内含丰富的源码资源,辅助您深入理解《C Prime Plus》和《C++ Pri...

gitblog_06704的博客 846

C Prime Plus编程练习(第二章)

1. #include &lt;stdio.h&gt; int main(void) { printf("Gustav Mahler\n"); printf("Gustav \nMahler\n"); printf("Gustav"); printf(" Mahler\n"); return 0; } 3. #include &lt;stdio.h&gt; int

每个片段都值得深深纪念 787

《C Primer Plus》编程练习—第14章

C Primer Plus第14章编程练习

chaofeng426的博客 1138
上一篇: C Prime Plus编程练习(第二章)
下一篇: C Prime Plus编程练习(第十一章)
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址