Ctrinhcon2
/* Ltrinh ham
a, Nhap danh sach n(n<=100) cac nhan vien gom hoten,tuoi,luong
b, Sap xep theo tuoi tang dan
c, Hien danh sach theo hang cot
d, Tinh tong(phu cap+luong) cua cac nhan vien (phu cap =30%luong)
e, Tim va in ra ten cua nhan vien bi lap lai nhieu nhat */
#include<conio.h>
#include<stdio.h>
#include<string.h>
typedef struct NV
{ char ht[25];
int t;
float lg;
};
NV a[100],tg;
int i,j,n;
float tong;
void cauA()
{ printf("nhap n:");
scanf("%d",&n);
for(i=0;i<n;i++)
{printf("Nhap ten:");
fflush(stdin);
gets(a[i].ht);
printf("Nhap tuoi:");
scanf("%d",a[i].t);
printf("Nhap luong:");
scanf("%f",a[i].lg);
}
void cauB()
{ for(i=0;i<n-1;i++)
for(j=i+1;j<n;j++)
if(a[i].t>a[j].t)
{tg=a[i];
a[i]=a[j];
a[j]=tg;
}
}
void cauC()
{ printf("
Danh sach la:");
for(i=0;i<n;i++)
printf("
%25s %10d %10f",a[i].ht,a[i].t,a[i].lg);
}
void cauD()
{ for(tong=0,i=0,i<n;i++)
tong+=a[i].lg*1.3f;
}
void main
{ clrscr();
cauA();
cauB();
cauC();
cauD();
getch();
}
Bạn đang đọc truyện trên: Truyen247.Pro