[cpp] TheCpp.cpp
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
- #define _CRT_SECURE_NO_WARNINGS
- #include "LearningCpp.h"
- #define check_leap(year) ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
- NotLearning::NotLearning() {
- ID = rand() % 1001 + 101;
- average = ((double)rand() * (100. - 0.)) / (double)RAND_MAX + 0.;
- static const std::string nameList[] = { "AHMET", "ABRAHAM", "ABIGAIL", "ABBIE", "AHMET", "ELIZABETH", "ELLA", "ELIZABETH", "AHMET", "ELLEN", "ELLEN", "ELLEN", "EPIPHANY", "EPPIE", "ETTA", "EULA", "FOREST", "FORD", "FOSTER", "FOX",
- "FOREST", "FORD", "FOSTER", "FOX", "EPIPHANY", "EPPIE", "ETTA", "EULA", "ABIGAIL", "ABBIE", "AHMET", "ELIZABETH", "ELLA", "ABRAHAM", "ABIGAIL", "ABBIE", "AHMET", "ELIZABETH", "ELLA", "EULA",
- "AHMET", "ABRAHAM", "ABIGAIL", "ABBIE", "AHMET", "ELIZABETH", "ELLA", "ELIZABETH", "AHMET", "ELLEN", "ELLEN", "ELLEN", "EPIPHANY", "EPPIE", "ETTA", "EULA", "FOREST", "FORD", "FOSTER", "FOX",
- "FOREST", "FORD", "FOSTER", "FOX", "EPIPHANY", "EPPIE", "ETTA", "EULA", "ABIGAIL", "ABBIE", "AHMET", "ELIZABETH", "ELLA", "ABRAHAM", "ABIGAIL", "ABBIE", "AHMET", "ELIZABETH", "ELLA", "EULA",
- };
- name = nameList[rand() % 80];
- static const std::string surnameList[] = { "JOHNSON", "ABBESTEGE", "WILSON", "JOHNSON", "ABBESTEGE", "HARRIS", "JOHNSON", "HARRIS", "WILSON", "JOHNSON", "GARCIA", "GARCIA", "JOHNSON", "RODRIGUEZ", "RODRIGUEZ", "COLEMAN", "WILSON",
- "JOHNSON", "ABBESTEGE", "WILSON", "JOHNSON", "GARCIA", "GARCIA", "JOHNSON", "RODRIGUEZ", "RODRIGUEZ" , "ABBESTEGE", "HARRIS", "JOHNSON", "HARRIS", "WILSON", "JOHNSON", "GARCIA",
- "JOHNSON", "ABBESTEGE", "WILSON", "JOHNSON", "ABBESTEGE", "HARRIS", "JOHNSON", "HARRIS", "WILSON", "JOHNSON", "GARCIA", "GARCIA", "JOHNSON", "RODRIGUEZ", "RODRIGUEZ", "COLEMAN", "WILSON",
- "WILSON", "JOHNSON", "GARCIA", "GARCIA", "JOHNSON", "RODRIGUEZ", "RODRIGUEZ", "COLEMAN", "WILSON", "JOHNSON", "ABBESTEGE", "WILSON", "ABBESTEGE", "HARRIS", "JOHNSON", "HARRIS",
- "WILSON", "JOHNSON", "GARCIA", "GARCIA", "JOHNSON", "RODRIGUEZ", "RODRIGUEZ", "COLEMAN", "WILSON", "JOHNSON", "ABBESTEGE", "WILSON", "JOHNSON", "ABBESTEGE",
- };
- surname = surnameList[rand() % 80];
- static const std::string cityList[] = { "Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Colorado",
- "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Connecticut", "Delaware", "Louisiana", "Maine", "Maryland", "Massachusetts",
- "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Connecticut", "Delaware",
- "Delaware", "Florida", "Georgia", "Hawaii", "Connecticut", "Delaware", "Louisiana", "Maine", "Maryland", "Massachusetts", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Connecticut", "Delaware",
- "Florida", "Georgia", "Hawaii", "Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida"
- };
- city = cityList[rand() % 80];
- year = rand() % (2020 - 1989 + 1) + 1989;
- static const int daytabs[][13] = {
- {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
- {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
- };
- static const std::string pmons[] = { "","Ocak","Subat","Mart","Nisan","Mayis","Haziran","Temmuz","Agustos","Eylul","Ekim","Kasim","Aralik" };
- int counter_date = rand() % 12 + 1;
- day = daytabs[check_leap(year)][counter_date];
- month = pmons[counter_date];
- }
- int NotLearning::getID()const
- {
- return ID;
- }
- int NotLearning::getDay()const
- {
- return day;
- }
- int NotLearning::getYear()const
- {
- return year;
- }
- double NotLearning::getAverage()const
- {
- return average;
- }
- std::string NotLearning::getName()const
- {
- return name;
- }
- std::string NotLearning::getSurname()const
- {
- return surname;
- }
- std::string NotLearning::getCity()const
- {
- return city;
- }
- std::string NotLearning::getMonth()const
- {
- return month;
- }
- void fillVector(std::vector<NotLearning>& newClass)
- {
- int total;
- std::cin >> total;
- for (int i = 0; i < total; i++)
- {
- NotLearning newStudent;
- newClass.push_back(newStudent);
- }
- }
- void showVector(const std::vector<NotLearning> newClass)
- {
- unsigned int size = newClass.size();
- std::cout << "Total size of vector: " << size << std::endl;
- std::cout << "Total capacity of vector: " << newClass.capacity() << std::endl;
- for (unsigned int i = 0; i < size; i++)
- {
- std::cout << "Student " << i << ": " << std::flush;
- std::cout << newClass[i].getID() << " " << std::flush;
- std::cout << newClass[i].getAverage() << " " << std::flush;
- std::cout << newClass[i].getName() << " " << std::flush;
- std::cout << newClass[i].getSurname() << " " << std::flush;
- std::cout << newClass[i].getCity() << " " << std::flush;
- std::cout << newClass[i].getDay() << " " << std::flush;
- std::cout << newClass[i].getMonth() << " " << std::flush;
- std::cout << newClass[i].getYear() << " " << std::endl;
- }
- std::cout << std::endl;
- }
- bool cmp_by_id(NotLearning& one, NotLearning& two)
- {
- return one.getID() < two.getID();
- }
- bool cmp_by_average(NotLearning& one, NotLearning& two)
- {
- return (one.getAverage() < two.getAverage());
- }
- bool cmp_by_name(NotLearning& one, NotLearning& two)
- {
- return one.getName() < two.getName();
- }
- bool cmp_by_surname(NotLearning& one, NotLearning& two)
- {
- return one.getSurname() < two.getSurname();
- }
- bool cmp_by_city(NotLearning& one, NotLearning& two)
- {
- return one.getCity() < two.getCity();
- }
- bool cmp_by_day(NotLearning& one, NotLearning& two)
- {
- return one.getDay() < two.getDay();
- }
- bool cmp_by_month(NotLearning& one, NotLearning& two)
- {
- return one.getMonth() < two.getMonth();
- }
- bool cmp_by_year(NotLearning& one, NotLearning& two)
- {
- return one.getYear() < two.getYear();
- }
- //Sorting the vector more detailed is still under construction.
- bool cmp_by_detail(NotLearning& one, NotLearning& two)
- {
- int cmp_result = (int)cmp_by_average(one, two);
- if (cmp_result)
- return cmp_result;
- cmp_result = cmp_by_id(one, two);
- if (cmp_result)
- return cmp_result;
- cmp_result = cmp_by_name(one, two);
- if (cmp_result)
- return cmp_result;
- cmp_result = cmp_by_surname(one, two);
- if (cmp_result)
- return cmp_result;
- cmp_result = cmp_by_city(one, two);
- if (cmp_result)
- return cmp_result;
- cmp_result = cmp_by_day(one, two);
- if (cmp_result)
- return cmp_result;
- cmp_result = cmp_by_month(one, two);
- if (cmp_result)
- return cmp_result;
- cmp_result = cmp_by_year(one, two);
- if (cmp_result)
- return cmp_result;
- return false;
- }
- void sortVectorByID(std::vector<NotLearning>& newClass)
- {
- // std::sort(newClass.begin(), newClass.end(), [](NotLearning& one, NotLearning& two) { return one.getID() < two.getID(); });
- std::sort(newClass.begin(), newClass.end(), cmp_by_id);
- }
- void sortVectorByAverage(std::vector<NotLearning>& newClass)
- {
- //std::sort(newClass.begin(), newClass.end(), [](NotLearning& one, NotLearning& two) { return one.getAverage() < two.getAverage(); });
- std::sort(newClass.begin(), newClass.end(),cmp_by_average);
- }
- void sortVectorByName(std::vector<NotLearning>& newClass)
- {
- //std::sort(newClass.begin(), newClass.end(), [](NotLearning& one, NotLearning& two) { return one.getName() < two.getName(); });
- std::sort(newClass.begin(), newClass.end(), cmp_by_name);
- }
- void sortVectorBySurname(std::vector<NotLearning>& newClass)
- {
- //std::sort(newClass.begin(), newClass.end(), [](NotLearning& one, NotLearning& two) { return one.getSurname() < two.getSurname(); });
- std::sort(newClass.begin(), newClass.end(), cmp_by_surname);
- }
- void sortVectorByCity(std::vector<NotLearning>& newClass)
- {
- //std::sort(newClass.begin(), newClass.end(), [](NotLearning& one, NotLearning& two) { return one.getCity() < two.getCity(); });
- std::sort(newClass.begin(), newClass.end(), cmp_by_city);
- }
- void sortVectorByDay(std::vector<NotLearning>& newClass)
- {
- //std::sort(newClass.begin(), newClass.end(), [](NotLearning& one, NotLearning& two) { return one.getDay() < two.getDay(); });
- std::sort(newClass.begin(), newClass.end(), cmp_by_day);
- }
- void sortVectorByMonth(std::vector<NotLearning>& newClass)
- {
- //std::sort(newClass.begin(), newClass.end(), [](NotLearning& one, NotLearning& two) { return one.getMonth() < two.getMonth(); });
- std::sort(newClass.begin(), newClass.end(), cmp_by_month);
- }
- void sortVectorByYear(std::vector<NotLearning>& newClass)
- {
- //std::sort(newClass.begin(), newClass.end(), [](NotLearning& one, NotLearning& two) { return one.getYear() < two.getYear(); });
- std::sort(newClass.begin(), newClass.end(), cmp_by_year);
- }
- //Sorting the vector more detailed is still under construction.
- void sortVectorByDetail(std::vector<NotLearning>& newClass)
- {
- std::sort(newClass.begin(), newClass.end(), cmp_by_detail);
- }
Editor
You can edit this paste and save as new: