😭
This commit is contained in:
+34
-34
@@ -1,34 +1,34 @@
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef struct book {
|
||||
string id;
|
||||
string name;
|
||||
double price;
|
||||
} book;
|
||||
|
||||
int input(book *books) {
|
||||
int length = 0;
|
||||
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) {
|
||||
return length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void output(book *books, int length) {
|
||||
for (int i = 0; i < length; i++) {
|
||||
cout << books[i].id << " " << books[i].name << " " << fixed << setprecision(2) << books[i].price << endl;
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
book books[100];
|
||||
int length = input(books);
|
||||
cout << length << endl;
|
||||
output(books, length);
|
||||
return 0;
|
||||
}
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef struct book {
|
||||
string id;
|
||||
string name;
|
||||
double price;
|
||||
} book;
|
||||
|
||||
int input(book *books) {
|
||||
int length = 0;
|
||||
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) {
|
||||
return length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void output(book *books, int length) {
|
||||
for (int i = 0; i < length; i++) {
|
||||
cout << books[i].id << " " << books[i].name << " " << fixed << setprecision(2) << books[i].price << endl;
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
book books[100];
|
||||
int length = input(books);
|
||||
cout << length << endl;
|
||||
output(books, length);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user