当前位置:网站首页>学生执勤问题
学生执勤问题
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;
}

边栏推荐
- C language review (modifier article)
- Sysevr environment configuration: joern-0.3.1, neo4j-2.1.5, py2neo2.0
- Uniapp monitor whether the app has a network connection
- JS string method Encyclopedia
- freemarker合并单元格,if、else标签的使用,null、空字符串处理
- Standard C language learning summary 6
- 小甲鱼C(第五章循环控制结构程序567)break和continue语句
- NAT-网络地址转换
- NAT network address translation
- Tutorial on regularization
猜你喜欢

shell---函数

rsync+inotify实现远程实时同步

Gd32f407 porting freertos+lwip

MOOC翁恺 C语言 第三周:判断与循环:2.循环

Basic knowledge of functions and special points

Leetcode then a deep copy of the linked list

MOOC Weng Kai C language fourth week: further judgment and circulation: 3. Multiple branches 4. Examples of circulation 5. Common errors in judgment and circulation

Freemaker exports word with tables and multiple pictures to solve the repetition and deformation of pictures

Result fill in the blank (dfs*c language)

Starting point Chinese website font anti crawling technology web page can display numbers and letters, and the web page code is garbled or blank
随机推荐
DHCP服务
Construction of Yum warehouse
开虚拟机KALI2022.2下安装GVM
Starting point Chinese website font anti crawling technology web page can display numbers and letters, and the web page code is garbled or blank
DOM Foundation
Shell --- conditional statement practice
DNS域名解析
OJ questions about fast and slow pointers in linked lists
Result fill in the blank (dfs*c language)
MOOC Weng Kai C language week 8: pointer and string: 1. Pointer 2. Character type 3. String 4. String calculation
MOOC翁恺 C语言 第三周:判断与循环:1.判断
Reptile learning summary
Review of C language (byte alignment)
C language review (modifier article)
shell---函数
C language review (pointer)
Blueberry pie Bluetooth debugging process
Standard C language learning summary 6
TOPK problem
Gd32f407 porting freertos+lwip