homeworklist.cpp
来自「SSD5 中EX1的参考答案 下载后请参照注释认真分析」· C++ 代码 · 共 93 行
CPP
93 行
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include "homeworklist.h"
using namespace std;
homeworklist::homeworklist()
{
current_size = 0;
}
bool homeworklist:: add (homework h)
{
if(current_size < LIST_MAX)
{
list[current_size] = h;
current_size++;
return 1;
}
else
{
return false;
}
}
homeworklist homeworklist:: dueafter (date d)
{
homeworklist hl = homeworklist();
int dateBool;
date d1 = date();
homework cmpDate = homework("",d1,d);
for(int i=0;i<current_size;i++)
{
dateBool = list[i].compareTo(cmpDate);
if(dateBool == 1)
{
hl.add(list[i]);
}
}
return hl;
}
homeworklist homeworklist:: duebefore (date d)
{
homeworklist hl = homeworklist();
int dateBool;
date d1 = date();
homework cmpDate = homework("",d1,d);
for(int i=0;i<current_size;i++)
{
dateBool = list[i].compareTo(cmpDate);
if(dateBool == -1)
{
hl.add(list[i]);
}
}
return hl;
}
homeworklist homeworklist:: dueon (date d)
{
homeworklist hl = homeworklist();
int dateBool;
date d1 = date();
homework cmpDate = homework("",d1,d);
for(int i=0;i<current_size;i++)
{
dateBool = list[i].compareTo(cmpDate);
if(dateBool == 0)
{
hl.add(list[i]);
}
}
return hl;
}
ostream &operator<< (ostream &stream, homeworklist hl)
{
for(int i = 0 ; i <hl.current_size ; i++)
{
stream << hl.list[i] << endl;
}
return stream;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?