2021年4月,为了简化班级早自习考勤签到流程,我利用校园卡,独立制作了一个简易考勤打卡系统。整个打卡系统一共花了我32元人民币。
首先我在网购软件上购买了一个能读取IC卡卡号的读卡器(现在网购软件上随手一找最便宜的那种就行了,现在好像20元左右就可以了,我的主要是不确定我们校园卡的ID号长度所以买的读取长度长),将所有同学的校园卡卡号存储到CSV文件中并与学号和姓名一一对应。 然后是程序的编写——通过C++文件流对CSV文件读取得到学生信息并存储到结构体中,运用标志数组判断每个同学是否已考勤……反正实现其实很简单,主要是知道读卡器上刷卡相当于在电脑在编辑的文件or程序框里面输入卡号并换行。 之后的早自习考勤,我只需要将读卡器连上电脑并运行程序,班级同学在读卡器刷一下校园卡或输入学号就可以进行考勤。 在考勤过程中,我还可以通过自己的查询命令,实时查询当次还没打卡的同学名单。同时,考勤程序实时将考勤信息输出到CSV文件,考勤结束后我可以通过输出的文件得知各位同学考勤的具体时间。 以下给出具体代码
#include
#include
#include
#include
#include
using namespace std;
struct Student{
string CardNum,StudentID,Name;
int Class,Num;
bool Sex;
}student[10000];
bool IsBeated[5050];
bool Checked[5050];
static string GetCurrentDateStr()
{
time_t t = time(NULL);
char ch[64] = {0};
strftime(ch, sizeof(ch) - 1, "%Y%m%d%p", localtime(&t));
return ch;
}
static string GetCurrentTimeStr()
{
time_t t = time(NULL);
char ch[64] = {0};
strftime(ch, sizeof(ch) - 1, "%H:%M:%S", localtime(&t));
return ch;
}
int main(){
cout
IsBeated[student[i].Class*100+student[i].Num]=0;
}
cout
if(temp.compare(student[i].CardNum)==0||temp.compare(student[i].StudentID)==0){
IsFound=1;
if(IsBeated[student[i].Class*100+student[i].Num]==1){
freopen("CON","w",stdout);
cout
if(IsBeated[student[i].Class*100+student[i].Num]==0&&Checked[student[i].Class*100+student[i].Num]==0){
NoHereNum++;
cout
cout |