当前位置:网站首页>Safflower STL
Safflower STL
2022-07-28 07:20:00 【▀】
requirement : The kindergarten organizes students by class , Students in each class are numbered according to their student number , The scale is 25 A child , One is used for school attendance every day bitset describe ,1 Represents attendance ,0 Representative absence , Try to write interface functions ,
Output the serial number and attendance of each child
Find the one with the highest attendance 3 A child gives the little red flower of the month .
data :
1111111111111111111111111 1110111011101110111011100 1101101101101101101101101 1111011110111101111011110 0011101110111101111101111 0011101111011111110111111 1111101111110111111100111 1100111110001111111111110 1111111111111101111111111 1111011111011111111110111 |
#include<iostream>
#include<vector>
#include<bitset>
#include<algorithm>
#include<fstream>
#include<string>
#include<iterator>
using namespace std;
template<size_t N>
class base
{
public:
bitset<N> b;
int id;
};
template<size_t N>
class com
{
public:
com() {}
bool operator()(const base<N>& b1, const base<N>&b2)
{
return b1.b.count() <= b2.b.count() ? false : true;
}
};
void main()
{
vector<char>v;
ifstream out("data.txt");
copy(istream_iterator<char>(out), istream_iterator<char>(), back_inserter(v));
vector<base<10>> vb(25);
cout << endl;
cout << endl; cout << endl;
for (int i=0;i<25;i++)
{
for (int j =0;j<10;j++)
{
vb[i].b.set(j, (v[j * 25 + i]-48));
}
vb[i].id = i;
cout << vb[i].b.to_string() << endl;
}
for (int i=0;i<25;i++)
{
cout << vb[i].b.count() << endl;
}
sort(vb.begin(),vb.end(),com<10>());
for (int i = 0; i < 25; i++)
{
cout << vb[i].b.to_string() <<" "<<vb[i].id<< endl;
}
cout << " Little Honghua's classmate is " << endl;
cout << vb[0].id <<" "<< vb[1].id << " " << vb[2].id << " " <<vb[3].id<<endl;
cin.get();
}test result :

边栏推荐
- Sysevr environment configuration: joern-0.3.1, neo4j-2.1.5, py2neo2.0
- joern运行后.joernindex数据库无内容
- object detection
- VNC Timed out waiting for a response from the computer
- Freemaker merges cells, uses if and else tags, and processes null and empty strings
- C language: understand the creation and destruction of function stack frames through an example
- MySQL excludes holidays and calculates the date difference
- Standard C language learning summary 9
- MySQL排除节假日,计算日期差
- Easypoi one to many, merge cells, and adapt the row height according to the content
猜你喜欢

2018-cvpr-Gesture Recognition: Focus on the Hands

NAT network address translation

The.Joernindex database has no content after Joern runs

Generate create table creation SQL statement according to excel

Install Nessus under win

metasploit渗透ms7_010练习

ThreadLocal那些事

js二级联动院系

Tailing microelectronics B91 general development board integrated into the trunk of openharmony community

Joern's code uses -devign
随机推荐
Basic knowledge of video format: let you know MKV, MP4, h.265, bit rate, color depth, etc
guava之限流RateLimiter
Open virtual machine kali2022.2 and install GVM
shell---函数
vcf文件制作
Redis主从复制原理及配置
Event_ Loop event loop mechanism
Nrf51822 review summary
232 (female) to 422 (male)
Layer 3 switching and VRRP
CAS vs 数据库乐观锁
heroku 操作总结
Pytorch extracts the feature map of a certain layer
Softmax multi classification gradient derivation
Raspberry pie serial port
New, let, VaR, const and temporary deadband. The difference between XML and JSON
Neo4j运行报错Error occurred during initialization of VM Incompatible minimum and maximum heap sizes spec
读取xml文件里switch节点的IP和设备信息,ping设备,异常显示在列表里
NoSQL之Redis配置与优化
guava之EventBus