初步完成实验1
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef struct book
|
||||
{
|
||||
string no;
|
||||
string name;
|
||||
double price;
|
||||
} book;
|
||||
|
||||
int main()
|
||||
{
|
||||
book books[100];
|
||||
int i = 0;
|
||||
|
||||
// input
|
||||
for (i; true; i++)
|
||||
{
|
||||
cin >> books[i].no >> books[i].name >> books[i].price;
|
||||
if (books[i].no == "0" && books[i].name == "0" && books[i].price == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
// output
|
||||
cout << i + 1 << endl;
|
||||
for (int j = 0; j <= i; j++)
|
||||
{
|
||||
cout << books[j].no << "\t" << books[j].name << "\t" << setprecision(2) << books[j].price << endl;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user