#include
using namespace std;
struct Book{
string name[100];
string price[100];
}book;
void Insearch(int n)
{
string tmp;
while (1)
{
cout << "please input the name of book that you find: ";
cin >> tmp;
for (int i = 0;i < n;i++)
{
if (tmp == book.name[i])
{
cout <<book.name[i]<<endl;
cout << book.price[i] << endl;
break;
}
if (i == n - 1 && tmp != book.name[i])
{
cout << “what you find does not exist, please try again!!” << endl;
}
}
}
}
int main()
{
cout << "please input the number of the book: “;
int n = 0;
cin >> n;
for (int i = 0;i < n;i++)
{
cout << “please input the name of” << i + 1<<”: ";
cin >> book.name[i];
cout << “please input the price of” << i + 1 << ": ";
cin >> book.price[i];
}
Insearch(n);
return 0;
}
图书搜索系统实现
本文介绍了一个简单的图书搜索系统实现过程,使用C++编程语言。系统允许用户输入图书数量及每本书的名称和价格,然后通过搜索功能查找并显示图书信息。此系统展示了基本的数据结构应用和用户交互设计。

573

被折叠的 条评论
为什么被折叠?



