当前位置:网站首页>学生执勤问题
学生执勤问题
2022-07-28 05:29:00 【▀】
给出每个月的执勤记录,计算出当月的执勤天数(STL)
学生:刘某某 1月份:111111111111111111110000000000000001 2月份:1010111110101111111111111110101010
#include<iostream>
#include<string>
#include<bitset>
#include<vector>
using namespace std;
template<size_t N>
class MyAttend
{
int month;
bitset<N>b;
public:
MyAttend(int mooth,string strAttend):b(strAttend)
{
this->month = mooth;
}
int GetMooth()
{
return month;
}
int GetAttendDays()
{
return b.count();
}
};
class Student
{
string name;
vector<MyAttend<31>*>v;
public:
Student(string name)
{
this->name = name;
}
void Add(MyAttend<31>&m)
{
v.push_back(&m);
}
void Add(int mooth,string&m)
{
MyAttend<31> * ma = new MyAttend<31>(mooth,m);
v.push_back(ma);
}
void showAttendDays()
{
cout << "姓名:" << name << endl;
cout << "月份:\t出勤天数" << endl;
for (int i=0;i<v.size();i++)
{
MyAttend<31>&m = *v.at(i);
int month = m.GetMooth();
int days = m.GetAttendDays();
cout << month << "\t" << days << endl;
}
}
};
int main()
{
Student stu("刘某某");
string s1 = "111111111111111111110000000000000001";
string s2 = "1010111110101111111111111110101010";
MyAttend<31>m1(1, s1);
stu.Add(m1);
stu.Add(2,s2);
stu.showAttendDays();
cin.get();
return 0;
}

边栏推荐
- ELK日志分析系统的部署
- SySeVR环境配置:joern-0.3.1、Neo4j-2.1.5、py2neo2.0
- PXE无人值守安装管理
- Bert的实现方法
- Easypoi one to many, merge cells, and adapt the row height according to the content
- Codesensor: convert the code into AST and then into text vector
- JS string method Encyclopedia
- Review of C language (byte alignment)
- 小甲鱼C(第五章循环控制结构程序567)break和continue语句
- shell---函数
猜你喜欢

主动扫描技术nmap详解

Leetcode then a deep copy of the linked list

Understanding of maximum likelihood estimation, gradient descent, linear regression and logistic regression

DHCP service

Media set up live broadcast server

SySeVR环境配置:joern-0.3.1、Neo4j-2.1.5、py2neo2.0

Joern的代码使用-devign

Blue bridge code error ticket

Redis哨兵模式及集群

Freemaker merges cells, uses if and else tags, and processes null and empty strings
随机推荐
MOOC Weng Kai C language week 5: 1. cycle control 2. multiple cycles 3. cycle application
分解路径为目录名和文件名的方法
Standard C language summary 4
NAT-网络地址转换
Leetcode then a deep copy of the linked list
Open virtual machine kali2022.2 and install GVM
Pictures are adaptive to the screen
Easypoi one to many, merge cells, and adapt the row height according to the content
爬虫学习总结
Shell --- conditional statement practice
Softmax multi classification gradient derivation
GFS分布式文件系统
OJ questions about fast and slow pointers in linked lists
PXE无人值守安装管理
Monotonic queue, Luogu p1886 sliding window
Reptile learning summary
VLAN configuration
Redis哨兵模式及集群
Metasploit penetration MS7_ 010 exercise
MOOC Weng Kai C language week 3: judgment and cycle: 1. Judgment