struct1
#include<iostream.h>
#include<iomanip.h>
#include<string.h>
#include<conio.h>
struct nhanvien
{
char ten[30];
char gt[5];
float luong;
float phucap;
float thunhap;
}; nhanvien nv[100];
void xuat(int n)
{
cout<<"TEN"<<setw(10)<<"NS"<<setw(10)<<"SEX"<<setw(10)<<"LUONG"<<setw(10)<<"PHUCAP"<<setw(10)<<"THUNHAP"<<endl;
for(int i=1;i<=n;i++)
cout<<nv[i].ten<<setw(10)<<nv[i].ns<<setw(10)<<nv[i].gt<<setw(10)<<nv[i].luong<<setw(10)<<nv[i].phucap<<setw(10)<<nv[i].thunhap<<endl;
}
void main()
{
clrscr();
cout<<"nhap so luong nhan vien:";cin>>n;
for(int i=1;i<=n;i++)
{
cout<<"nhap thong tin cho nv thu:"<<i<<endl;
cout<<"nhap ten nhan vien:";
cin.ignore(1);cin.get(nv[i].ten,30);
do
{
cout<<"nhap nam sinh:";
cin>>nv[i].ns;
}while(nv[i].ns<1970 || nv[i].ns>1995);
do
{
cout<<"nhap gioi tinh:";
cin.ignore(1);cin.get(nv[i].gt,5);
}while((strcmp(nv[i].gt,"nam")!=0));
cout<<"nhap luong:";
cin>>nv[i].luong;
cout<<"nhap phu cap:";
cin>>nv[i].phucap;
nv[i].thunhap=nv[i].luong+nv[i].phucap;
}
cout<<"Danh Sach nhan vien vua nhap:"<<endl;
xuat(n);
cout<<"NV nam ko phu cap hoac muc luong>1tr:"<<endl;
for(i=1;i<=n;i++)
if(strcmp(nv[i].gt,"nam")==0 && (nv[i].phucap==0 || nv[i].luong>1000000))
cout<<nv[i].ten<<endl;
cout<<"nv sinh truoc 1986 va co luong cao nhat:"<<endl;
float max;
for(i=1;i<=n;i++)
if(nv[i].ns<1986)
max=nv[i].luong;
for(i=1;i<=n;i++)
if(nv[i].luong<1986 && max<nv[i].luong)
max=nv[i].luong;
cout<<nv[i].ten;
cout<<"tim kiem"<<endl;
char nhap[100];
cout<<"nhap ten can tim:";cin.ignore(1);cin.get(nhap,30);
for(i=1;i<=n;i++)
if(strcmp(nhap,nv[i].ten)==0)
cout<<"tim thay "<<nv[i].ten;
cout<<"sap xep:"<<endl;
for(i=1;i<n;i++)
for(int j=i+1;j<=n;j++)
if(nv[i].luong>nv[j].luong)
{
nhanvien tg=nv[i];
nv[i]=nv[j];
nv[j]=tg;
}
xuat(n);
getch()}
Bạn đang đọc truyện trên: AzTruyen.Top