将所有第一二三题模块化

This commit is contained in:
2024-09-26 01:08:48 +08:00
parent c5cd37b2a9
commit 7e8bb17c72
3 changed files with 34 additions and 18 deletions
+13 -5
View File
@@ -15,18 +15,26 @@ void alter_to_110_percent(book *books, int length) {
}
}
int main() {
book books[100];
int input(book *books) {
int length = 0;
for (length = 0; true; length++) {
for (int 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;
return length;
}
}
alter_to_110_percent(books, length);
}
void output(book *books, int length) {
for (int i = 0; i < length; i++) {
cout << books[i].id << "\t" << books[i].name << "\t" << fixed << setprecision(2) << books[i].price << endl;
}
}
int main() {
book books[100];
int length = input(books);
alter_to_110_percent(books, length);
output(books, length);
return 0;
}