Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- typedef struct{
- int d,m,y;//day,month,year
- }date;
- /*
- struct a{
- int d,m,y;
- }date;*/
- typedef struct{
- char name[20];
- date start;
- float salary;
- }employee;
- void input(employee e[],int n){
- int i=0;
- while(i<n){
- printf("NAME#%d :",i+1);
- scanf("%s",e[i].name); fflush(stdin);
- printf("START#%d :",i+1);
- scanf("%d/%d/%d",&e[i].start.d,&e[i].start.m,&e[i].start.y);
- // fflush(stdin);
- printf("SALARY#%d :",i+1);
- scanf("%f",&e[i].salary);
- i++;
- }
- }
- employee incsalary(employee e,float p){
- e.salary = e.salary+((e.salary*p)/100);
- return e;
- }
- employee findemp(employee e[ ], int n){
- employee max = e[0];
- int i=0;
- while(i<n){
- if(e[i].start.y<max.start.y){
- max = e[i];
- }
- else if(e[i].start.y==max.start.y){
- if(e[i].start.m<max.start.m){
- max=e[i];
- }
- else if(e[i].start.m==max.start.m){
- if(e[i].start.d<max.start.d){
- max=e[i];
- }
- }
- }
- i++;
- }
- printf("\n%s %d/%d/%d %f\n",max.name,max.start.d,max.start.m,max.start.y,max.salary);
- return max; // nott foget
- }
- employee display(employee e[ ], int n){
- }
- int main(){
- //test
- int n=2;
- float p=3.5;
- employee data[n],max;
- input(data,n);
- int i=0;
- while(i<n){
- data[i]=incsalary(data[i],p);
- i++;
- }
- display(data,n);
- max=findemp(data,n);
- //printf("%s %d/%d/%d %f\n",max.name,max.start.d,max.start.m,max.start.y,max.salary);
- return 0;
- }
Add Comment
Please, Sign In to add comment