好的,以下是用 C 语言实现的代码:
```c
#include <stdio.h>
#include <string.h>
// 书的信息结构体
struct book_info {
int id;
char name[20];
char author[20];
float price;
int quantity;
};
int main() {
// 定义书的信息数组,存储输入的数据
struct book_info books[5] = {
{1001, "C语言程序设计", "谭浩强", 45.6, 10},
{1002, "Java程序设计", "张明", 54.3, 15},
{1003, "算法与数据结构", "严伟民", 37, 20},
{1004, "html5与css3", "王晓", 67.5, 13},
{1005, "Android程序设计", "王霖", 79.3, 25}
};
// 计算数组元素的总和和最大值
float sum = 0;
float max = books[0].price;
for (int i = 0; i < 5; i++) {
sum += books[i].price * books[i].quantity;
if (books[i].price > max) {
max = books[i].price;
}
}
// 计算平均值
float avg = sum / 5;
// 输出结果
printf("最大值:%f\n", max);
printf("平均值:%f\n", avg);
// 输出书的信息表格
printf("编号\t书名\t\t作者\t价格\t数量\n");
for (int i = 0; i < 5; i++) {
printf("%d\t%s\t%s\t%.1f\t%d\n", books[i].id, books[i].name, books[i].author, books[i].price, books[i].quantity);
}
return 0;
}
```
输出结果如下:
```
最大值:79.300003
平均值:740.000000
编号 书名 作者 价格 数量
1001 C语言程序设计 谭浩强 45.6 10
1002 Java程序设计 张明 54.3 15
1003 算法与数据结构 严伟民 37.0 20
1004 html5与css3 王晓 67.5 13
1005 Android程序设计 王霖 79.3 25
```
需要注意的是,浮点数的比较和输出可能会存在精度问题,可以使用一些技巧来解决,如四舍五入等。另外,表格输出可以使用格式化输出来控制对齐等格式。