Advertisement
Guest User

sr

a guest
Jan 16th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<stdlib.h>
  4.  
  5.  
  6. struct Employee
  7. {
  8.     char name[20];
  9.     int age;
  10.     long salary;
  11.     char position[15];
  12.  
  13.     Employee()
  14.     {
  15.         ;
  16.     }
  17.     Employee(char _name, int _age, char _position, long _salary)
  18.     {
  19.         char name= _name;
  20.         int age= _age;
  21.  
  22.         long salary = _salary;
  23.         char position= _position;
  24.     }
  25.      void printInfo() {
  26.         printf("Name: %s, Age: %d, Salary: %ld, Position: %s\n", name,age,salary,position);
  27.     }
  28. };
  29.  
  30. typedef struct Employee em;
  31. struct node
  32. {
  33.     char name;
  34.     int age;
  35.     double salary;
  36.     char position;
  37. } st[1000];
  38.  bool sort_Employees_salary(node a,node b)
  39. {
  40.     return a.salary < b.salary ;
  41. }
  42.  
  43. int main() {
  44.     int n;
  45.     scanf("%d", &n);
  46.  
  47.    em Employee[100];
  48.  
  49.     for(int i = 0; i < n; ++i) {
  50.         scanf("%s %d %ld %s", &Employee[i].name, &Employee[i].age, &Employee[i].salary, &Employee[i].position);
  51.     }
  52.  
  53.     for(int i = 0; i < n; ++i)
  54.         Employee[i].printInfo();
  55.  
  56.       sort (st,st+n,sort_Employees_salary);
  57.  
  58.  
  59.  
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement