Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <fstream>
- #include <sstream>
- #include <string>
- class Ember {
- public:
- int eletkor;
- int fizetes;
- Ember(int e, int f) {
- this->eletkor = e;
- this->fizetes = f;
- }
- };
- std::vector<Ember> emberek;
- std::vector<Ember> beolvas(std::string filenev);
- int feladat1(std::vector<Ember> v);
- int feladat2(std::vector<Ember> v);
- int feladat3(std::vector<Ember> v);
- std::vector<int> feladat4(std::vector<Ember> v);
- std::vector<int> f4;
- int main() {
- emberek = beolvas("be1.txt");
- //std::cout << "Bolvasva..." << std::endl;
- std::cout << "" << feladat1(emberek) << std::endl;
- std::cout << "" << feladat2(emberek) << std::endl;
- std::cout << "" << feladat3(emberek) << std::endl;
- f4 = feladat4(emberek);
- std::cout << f4.size();
- for (int i = 0; i < f4.size(); ++i) {
- std::cout << " " << (f4.at(i)+1);
- }
- std::cout << std::endl;
- return 0;
- }
- std::vector<Ember> beolvas(std::string filenev) {
- std::ifstream s(filenev.c_str());
- std::string line;
- std::getline(std::cin, line, '\n');
- std::vector<Ember> res;
- while (std::getline(std::cin, line)) {
- std::istringstream iss(line);
- int e,f;
- iss >> e >> f;
- res.push_back(Ember(e,f));
- }
- return res;
- }
- int feladat1(std::vector<Ember> v) {
- int i = 1;
- int r = 0;
- Ember a = v.at(0);
- while (i < v.size()) {
- if (v.at(i).eletkor > v.at(r).eletkor) {
- r = i;
- }
- i++;
- }
- return r+1;
- }
- int feladat2(std::vector<Ember> v) {
- int sum = 0;
- for (int i = 0; i < v.size() ; i++) {
- if (v.at(i).eletkor > 40 && v.at(i).fizetes < 200000) {
- sum++;
- }
- }
- return sum;
- }
- int feladat3(std::vector<Ember> v) {
- bool e[150];
- for (int i = 0; i < 150; i++) {
- e[i] = false;
- }
- int sum = 0;
- for (int i = 0; i < v.size(); i++) {
- if (e[v.at(i).eletkor] == false) {
- e[v.at(i).eletkor] = true;
- sum++;
- }
- }
- return sum;
- }
- std::vector<int> feladat4(std::vector<Ember> v) {
- std::vector<int> res;
- for (int i = 0; i < v.size(); i++) {
- if (v.at(i).eletkor < 30) {
- res.push_back(i);
- }
- }
- return res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement