Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- enum typeE {employee = 0, manager = 1, owner = 2};
- class Employee{
- private:
- char name[50];
- float salary;
- typeE wp;
- void copy(const Employee &e){
- strcpy(this->name,e.name);
- this->salary=e.salary;
- this->wp=e.wp;
- }
- public:
- Employee(char *name = "",float salary = 0,typeE wp = employee){
- strcpy(this->name,name);
- this->salary=salary;
- this->wp=wp;
- }
- Employee(const Employee &e){
- copy(e);
- }
- typeE getWp(){
- return wp;
- }
- float getSalary(){
- return salary;
- }
- char getName(){
- return *name;
- }
- bool operator >(Employee &e){
- if(this->getSalary() > e.getSalary()){
- return true;
- }
- }
- friend ostream& operator<<(ostream &out,const Employee &e)
- {
- out<<e.name<<" "<<e.salary<<" ";
- if(e.wp == employee) out<<"Employee"<<endl;
- if(e.wp == manager) out<<"Manager"<<endl;
- if(e.wp == owner) out <<"Owner"<<endl;
- return out;
- }
- };
- void sort(Employee emp[],int n){
- for(int i=0;i<n;i++)
- {
- for(int j=i+1;j<n;j++)
- {
- if(emp[i]>emp[j])
- {
- Employee temp=emp[i];
- emp[i]=emp[j];
- emp[j]=temp;
- }
- }
- }
- }
- int main(){
- int n;
- std::cout<<"Vnesi broj na vraboteni"<<std::endl;
- std::cin >> n;
- Employee emp[n];
- for(int i=0; i<n; i++) {
- char *name;
- float salary;
- int wp;
- typeE type;
- std::cin >> name;
- std::cin >> salary;
- std::cin >> wp;
- emp[i]= Employee (name,salary,type);
- }
- sort(emp,n);
- for(int i=0;i<n;i++){
- cout<<emp[i]<<endl;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment