Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- #include<stdlib.h>
- struct Employee
- {
- char name[20];
- int age;
- long salary;
- char position[15];
- Employee()
- {
- ;
- }
- Employee(char _name, int _age, char _position, long _salary)
- {
- char name= _name;
- int age= _age;
- long salary = _salary;
- char position= _position;
- }
- void printInfo() {
- printf("Name: %s, Age: %d, Salary: %ld, Position: %s\n", name,age,salary,position);
- }
- };
- typedef struct Employee em;
- struct node
- {
- char name;
- int age;
- double salary;
- char position;
- } st[1000];
- bool sort_Employees_salary(node a,node b)
- {
- return a.salary < b.salary ;
- }
- int main() {
- int n;
- scanf("%d", &n);
- em Employee[100];
- for(int i = 0; i < n; ++i) {
- scanf("%s %d %ld %s", &Employee[i].name, &Employee[i].age, &Employee[i].salary, &Employee[i].position);
- }
- for(int i = 0; i < n; ++i)
- Employee[i].printInfo();
- sort (st,st+n,sort_Employees_salary);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement