Ai
1 Star 0 Fork 0

水兵/Project1

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
databaseCurrentCourse.cpp 1.36 KB
一键复制 编辑 原始数据 按行查看 历史
水兵 提交于 2020-03-25 21:13 +08:00 . 修复
#include "databaseCurrentCourse.h"
#include"agori.h"
#include"ADEQ.h"
databaseCurrentCourse::databaseCurrentCourse()
{
pathBase = "current_course.txt";
}
bool databaseCurrentCourse::isFileExsist(string path){
ifstream fin(path);
if (!fin.is_open()){
return 0;
}
else{
return 1;
fin.close();
}
}
int databaseCurrentCourse::readFromFile(string path)
{
ifstream fin(path);
if (!fin.is_open()){
return 1;
}
int id, cap, sel;
string name, tea, type;
fin >> id >> name >> tea >> cap >> sel >> type;
while (!fin.eof()){
if (!pCourse.queryHasKey(to_string(id))){
string stId = to_string(id);
pCourse.addKey(stId);
pCourse.add(stId, 1, name);
pCourse.add(stId, 2, tea);
pCourse.add(stId, 3, to_string(cap));
pCourse.add(stId, 4, to_string(sel));
pCourse.add(stId, 5, type);
}
fin >> id >> name >> tea >> cap >> sel >> type;
}
fin.close();
writeToFile(pathBase);
return 0;
}
bool databaseCurrentCourse::writeToFile(string path)
{
ofstream fout(path);
if (!fout.is_open()){
return 1;
}
else{
For(i, 0, int(pCourse.graph.size()) - 1){
fout << str_toStringId(atoi(pCourse.graph[i][0][0])) << "\t" << pCourse.graph[i][1][0] << "\t" << pCourse.graph[i][2][0] << "\t" << pCourse.graph[i][3][0] << "\t" << pCourse.graph[i][4][0] << "\t" << pCourse.graph[i][5][0] << endl;
}
fout.close();
return 0;
}
}
databaseCurrentCourse dataCourse;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/Shbinging/Project1.git
git@gitee.com:Shbinging/Project1.git
Shbinging
Project1
Project1
master

搜索帮助