Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <<<<<<<<<<<<<<<<<<<BinhChon.h>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- #pragma once
- #include <iostream>
- #include <string>
- #include <conio.h>
- #define _CRT_SECURE_NO_WARNINGS
- using namespace std;
- class BinhChon
- {
- private:
- string TimeStart;
- string TimeEnd;
- string TimeStart1min;
- string TimeEnd1min;
- string Hour;
- string Minnute;
- string Vote_Code;// mã số bình chọn
- string Vote_NameSinger;// Tên Ca Sĩ Bình Chọn;
- public:
- int Getter_TimeStart();
- int Getter_TimeStart1min();
- int Getter_TimeEnd();
- int Getter_TimeEnd1min();
- int Getter_Hour();
- int Getter_Minnute();
- string Getter_Vote_Code();
- string Getter_Vote_NameSinger();
- public:
- void EnterTheTime();
- bool CheckTime();
- void input();
- BinhChon();
- ~BinhChon();
- };
- <<<<<<<<<<<<<<<<<<<<<<<<BinhChon.cpp>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- #include "BinhChon.h"
- void BinhChon::input()
- {
- cin >> Vote_Code;
- //cin.seekg(1, cin.cur);
- getline(cin, Vote_NameSinger, '\n');// nhập tên ca sĩ;
- Vote_NameSinger = Vote_NameSinger.substr(0, Vote_NameSinger.size() - 6);
- cin.seekg(-7, cin.cur);
- getline(cin, Hour, ':');// nhập giờ:
- //Hour.substr(0, 1);
- getline(cin, Minnute, '\n');// nhập phút:
- //Minnute.substr(0, 1);
- }
- void BinhChon::EnterTheTime()
- {
- getline(cin, TimeStart, ':');// giờ bắt đầu
- getline(cin, TimeStart1min, ' ');//phút bắt đầu
- getline(cin, TimeEnd, ':');// giờ kết thúc
- getline(cin, TimeEnd1min);// phút kết thúc
- }
- bool BinhChon::CheckTime()
- {
- int a = (Getter_TimeStart() * 60) + Getter_TimeStart1min(); // giờ bắt đầu + phút bắt đầu
- int b = (Getter_TimeEnd() * 60) + Getter_TimeEnd1min();// giờ kết thúc + phút kết thúc
- int temp = (Getter_Hour() * 60) + Getter_Minnute();// giờ + phút hiện tại
- if (temp >= a && temp <= b) // duyệt a và b nếu thời gian hiện nằm trong khoảng thời gian bắt đầu và kết thúc
- {
- return true;
- }
- return false;
- }
- int BinhChon::Getter_TimeStart()
- {
- return (stof(TimeStart));
- }
- int BinhChon::Getter_TimeStart1min()
- {
- return (stof(TimeStart1min));
- }
- int BinhChon::Getter_TimeEnd()
- {
- return(stof(TimeEnd));
- }
- int BinhChon::Getter_TimeEnd1min()
- {
- return(stof(TimeEnd1min));
- }
- int BinhChon::Getter_Hour()
- {
- return(stof(Hour));
- }
- int BinhChon::Getter_Minnute()
- {
- return(stof(Minnute));
- }
- string BinhChon::Getter_Vote_Code()
- {
- return Vote_Code;
- }
- string BinhChon::Getter_Vote_NameSinger()
- {
- return Vote_NameSinger;
- }
- BinhChon::BinhChon()
- {
- }
- BinhChon::~BinhChon()
- {
- }
- <<<<<<<<<<<<<<<<<<<<<<main.cpp>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- #include "BinhChon.h"
- int main()
- {
- int dem[7] = { 0,0,0,0,0,0,0 };
- freopen("input.txt", "rt", stdin);
- BinhChon DanhSach[100];
- int n = 0;
- BinhChon temp;
- temp.EnterTheTime();
- while (!cin.eof())
- {
- temp.input();
- if (temp.CheckTime() == true)
- {
- DanhSach[n] = temp;
- n++;
- }
- }
- freopen("output.txt", "wt", stdout);
- for (int i = 0; i < n; i++)
- {
- for (int j = i; j < n; j++)
- {
- if (DanhSach[j].Getter_Vote_Code() == DanhSach[i].Getter_Vote_Code())
- {
- dem[i]++;
- }
- }
- }
- int Max = 0;
- for (int i = 0; i < n; i++)
- {
- if (dem[i] > Max)
- {
- Max = dem[i];
- }
- }
- for (int i = 0; i < n; i++)
- {
- if (Max == dem[i])
- {
- cout << DanhSach[i].Getter_Vote_NameSinger() << " " << dem[i] << endl;
- }
- }
- _getch();
- }
Add Comment
Please, Sign In to add comment