网站放到国外空间,农业公司网站建设方案,商丘优化公司,网页制作教程赵丰年第三版C/PTA —— 14.结构体1#xff08;课内实践#xff09; 6-1 计算两个复数之积6-2 结构体数组中查找指定编号人员6-3 综合成绩6-4 结构体数组按总分排序 6-1 计算两个复数之积 struct complex multiply(struct complex x, struct complex y)
{struct complex product;product.… C/PTA —— 14.结构体1课内实践 6-1 计算两个复数之积6-2 结构体数组中查找指定编号人员6-3 综合成绩6-4 结构体数组按总分排序 6-1 计算两个复数之积 struct complex multiply(struct complex x, struct complex y)
{struct complex product;product.real x.real * y.real - x.imag * y.imag;product.imag x.real * y.imag x.imag * y.real;return product;
}6-2 结构体数组中查找指定编号人员 struct student fun(struct student* std, char* num)
{struct student product;for (int i 0; i 8; i){if (std[i].num[0] num[0])product std[i];}return product;}6-3 综合成绩 double getAverage(Applicant* a)
{double sum 0.0;sum a-computational * 1.0 * 0.4 a-humanistic * 1.0 * 0.5 a-logical * 1.0 * 0.3 a-presentation * 1.0 * 0.6 a-scientific * 1.0 * 0.8;return sum;
}6-4 结构体数组按总分排序 void calc(struct student* p, int n)
{for (int i 0; i n; i){for (int j 0; j 3; j){p[i].sum p[i].score[j];}}
}
void sort(struct student* p, int n)
{struct student tmp;for (int i 0; i 4; i){for (int j i1; j 5; j){if (p[i].sum p[j].sum){tmp p[j];p[j] p[i];p[i] tmp;}}}
}