VS 错误: cout,cin不明确

#include <iostream> #include <cstring> #include <algorithm> #define MAX_CAPACITY 100 // 最大容量限制 typedef struct { char no[8]; // 图书编号 char name[20]; // 书名 float price; // 价格 } Book; typedef struct { Book* elem; // 存储空间基址 int length; // 当前长度 int capacity; // 总容量 } SqList; // 初始化顺序表 void InitList(SqList& L, int size) { L.elem = new Book[size]; L.length = 0; L.capacity = size; } // 输入图书信息 void InputBooks(SqList& L, int n) { if (n > L.capacity) { std::cout << "超出最大容量!" << std::endl; return; } for (int i = 0; i < n; i++) { std::cout << "输入第" << i+1 << "本图书信息(编号 书名 价格): "; std::cin >> L.elem[i].no >> L.elem[i].name >> L.elem[i].price; L.length++; } } // 显示所有图书 void DisplayAll(SqList& L) { if (L.length == 0) { std::cout << "暂无图书信息!" << std::endl; return; } std::cout << "\n编号\t书名\t价格" << std::endl; for (int i = 0; i < L.length; i++) { std::cout << L.elem[i].no << "\t" << L.elem[i].name << "\t" << L.elem[i].price << std::endl; } } // 按书名查找 void SearchByName(SqList& L, char* name) { bool found = false; for (int i = 0; i < L.length; i++) { if (strcmp(L.elem[i].name, name) == 0) { std::cout << "找到图书:" << L.elem[i].no << "\t" << L.elem[i].name << "\t" << L.elem[i].price << std::endl; found = true; } } if (!found) std::cout << "未找到该图书!" << std::endl; } // 插入图书 void InsertBook(SqList& L, int pos, Book book) { if (pos < 1 || pos > L.length + 1) { std::cout << "无效位置!" << std::endl; return; } if (L.length >= L.capacity) { std::cout << "存储空间已满!" << std::endl; return; } for (int i = L.length; i >= pos; i--) { L.elem[i] = L.elem[i 把这个代码补充完善
03-08
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值