#include <stdio.h>
#include <string.h>
// 定义Book结构体
struct Book {
char title[100];
char author[50];
float price;
int publicationYear;
};
// 更新书籍价格的函数
void updateBookPrice(struct Book *books[], int size) {
for (int i = 0; i < size; i++) {
if (books[i]->publicationYear >= 2010) {
books[i]->price = books[i]->price * 1.1;
}
}
}
int main() {
struct Book book1 = {"C Programming Language", "Brian W. Kernighan", 29.99, 1988};
struct Book book2 = {"Effective Java", "Joshua Bloch", 49.99, 2008};
struct Book book3 = {"Clean Code", "Robert C. Martin", 39.99, 2008};
struct Book book4 = {"Python Crash Course", "Eric Matthes", 34.99, 2015};
struct Book *books[] = {&book1, &book2, &book3, &book4};
int size = sizeof(books) / sizeof(books[0]);
updateBookPrice(books, size);
for (int i = 0; i < size; i++) {
printf("Title: %s\n", books[i]->title);
printf("Author: %s\n", books[i]->author);
printf("Price: %.2f\n", books[i]->price);
printf("Publication Year: %d\n\n", books[i]->publicationYear);
}
return 0;
}