初步完成第三题

This commit is contained in:
2024-09-26 00:57:27 +08:00
parent 39e4029b9c
commit f2061faf17
3 changed files with 35 additions and 2 deletions
+32
View File
@@ -0,0 +1,32 @@
#include <iostream>
#include <iomanip>
using namespace std;
typedef struct {
string id;
string name;
double price;
} book;
void alter_to_110_percent(book *books, int length) {
for (int i = 0; i < length; i++) {
books[i].price = books[i].price * 1.1;
}
}
int main() {
book books[100];
int length = 0;
for (length = 0; true; length++) {
cin >> books[length].id >> books[length].name >> books[length].price;
if (books[length].id == "0" && books[length].name == "0" && books[length].price == 0) {
break;
}
}
alter_to_110_percent(books, length);
for (int i = 0; i < length; i++) {
cout << books[i].id << "\t" << books[i].name << "\t" << fixed << setprecision(2) << books[i].price << endl;
}
return 0;
}