#include
#include
using namespace std;
typedef struct wage {
char unit[8];
char name[10];
char sex[4];
char birthdate[12];
char title[20];
double basewage;
double subsidy;
double tax;
double expenses;
double residualwage;
}WAGE;
void ComputerResidualwage(WAGE a[],int n) {
for(int i = 0; i < n; ++i)
a[i].residualwage = a[i].basewage + a[i].subsidy - a[i].tax - a[i].expenses;
}
void PrintTitle(void) {
cout << "单 位 姓 名 性别 出生年月 职 称 基本工资 津 贴 个 税 水电费 实发工资\n";
for(int i = 0; i < 79; ++i) cout << "*"; cout << endl;
}
void RowShow(WAGE a[], int i) {
cout << a[i].unit << " ";
if(strlen(a[i].name) == 4) {
a[i].name[6] = a[i].name[4];
a[i].name[5] = a[i].name[3];
a[i].name[4] = a[i].name[2];
a[i].name[2] = a[i].name[3] = ' ';
}
cout << a[i].name << " " << a[i].sex << " " << a[i].birthdate;
if(strlen(a[i].title) == 4) {
a[i].title[6] = a[i].title[4];
a[i].title[5] = a[i].title[3];
a[i].title[4] = a[i].title[2];
a[i].title[2] = a[i].title[3] = ' ';
}
cout << " " << a[i].title << " ";
cout.precision(2);
cout.width(8);
cout << fixed << a[i].basewage << " "; cout.width(6);
cout << fixed << a[i].subsidy << " ";
cout.width(8);
cout << fixed << a[i].tax << " ";
cout.width(6);
cout << fixed << a[i].expenses << " ";
cout.width(8);
cout << fixed << a[i].residualwage << endl;
}
void Show(WAGE a[], int n) {
for(int i = 0; i < n; ++i) RowShow(a,i);
}
void Search1(WAGE a[], int n) {
int i,flag = 1;
for(i = 0; i < n; ++i) {
if(strcmp(a[i].unit,"理学院") == 0 && a[i].basewage > 900.00 &&
strcmp(a[i].title,"副教授") == 0 && strcmp(a[i].sex,"男") == 0) {
RowShow(a,i);
flag = 0;
}
}
if(flag) cout << "(没找到符合条件者)\n";
}
void Search2(WAGE a[], int n) {
int i,flag = 1;
for(i = 0; i < n; ++i) {
if(strcmp(a[i].unit,"理学院") == 0 && a[i].basewage < 1200.00 &&
strcmp(a[i].title,"教 授") == 0 && strcmp(a[i].sex,"男") == 0) {
RowShow(a,i);
flag = 0;
}
}
if(flag) cout << "(没找到符合条件者)\n";
}
int main() {
WAGE a[] = {
{"理学院","赵志军","男","1957-06-25","教 授",1150,411,176.6,90},
{"商学院","于 铭","女","1979-10-21","助 教",500,471,208.9,91},
{"工学院","许炎锋","女","1954-03-08","教 授",1250,630,306.2,96},
{"理学院","王 嘉","女","1971-06-06","讲 师",850,475,100.3,89},
{"工学院","李新江","男","1962-10-02","教 授",950,399,49.5,87},
{"商学院","郭海英","女","1963-02-07","副教授",950,332,77.6,85},
{"工学院","马淑恩","女","1960-06-09","副教授",900,791,60.5,45},
{"理学院","王金科","男","1956-09-10","教 授",1050,480,325.6,93},
{"理学院","李东慧","女","1950-08-07","教 授",1350,364,52.3,94},
{"工学院","张 宁","女","1980-01-01","助 教",500,395,78,89},
{"商学院","王 孟","男","1966-09-08","讲 师",800,463,220.3,98},
{"工学院","马会爽","女","1970-02-09","讲 师",800,368,101.1,69},
{"工学院","史晓赟","女","1952-06-06","教 授",1200,539,520.3,50},
{"理学院","刘燕凤","女","1959-08-07","教 授",1200,892,180.9,86},
{"工学院","齐 飞","男","1961-04-05","副教授",1200,626,245.6,74},
{"商学院","张 娟","女","1975-09-25","助 教",650,374,625.3,86},
{"理学院","潘成文","男","1965-10-09","讲 师",950,402,1050,90},
{"工学院","邢 易","女","1981-02-25","助 教",600,325,300,90},
{"商学院","谢枭豪","女","1950-11-18","教 授",1350,516,200,90},
{"工学院","胡洪静","女","1952-06-24","教 授",1350,277,100,86},
{"工学院","李云飞","男","1969-05-04","讲 师",960,729,56,89},
{"商学院","张 奇","女","1970-05-28","讲 师",960,331,69,89},
{"理学院","夏小波","女","1968-08-01","讲 师",960,482,89,45},
{"工学院","王 玮","女","1972-11-05","讲 师",960,340,98,79},
{"理学院","张 帝","女","1950-03-26","教 授",1300,335,124,90},
{"商学院","孙 帅","男","1966-05-24","讲 师",900,748,326,79},
{"工学院","卜辉娟","女","1960-05-23","教 授",960,481,651,78},
{"工学院","李辉玲","女","1978-09-09","助 教",630,379,400,77},
{"理学院","刘亚静","男","1969-08-09","副教授",890,377,23,66},
{"工学院","尹 娴","女","1958-06-09","教 授",1050,955,59,65},
{"商学院","马春英","男","1964-12-06","讲 师",850,387,78,69},
{"工学院","孟 梦","女","1965-08-09","副教授",850,753,485.6,93},
{"工学院","梁晓萌","女","1975-06-09","助 教",650,551,136.5,99},
{"理学院","张 然","女","1973-03-03","讲 师",800,761,203.1,100},
{"工学院","彭雁南","男","1978-05-09","助 教",650,200,200,90}
};
int i,n = sizeof(a)/sizeof(a[0]);
if(n == 0) return 1;
ComputerResidualwage(a,n);
PrintTitle();
for(i = 0; i < n; ++i) RowShow(a,i);
for(i = 0; i < 79; ++i) cout << "*";
cout << endl; cout << "\n理学院,基本工资高于900元的男副教授有:\n\n";
PrintTitle();
Search1(a,n);
for(i = 0; i < 79; ++i) cout << "*";
cout << endl;
cout << "\n理学院,基本工资低于1200元的男教授有:\n\n";
PrintTitle();
Search2(a,n);
for(i = 0; i < 79; ++i) cout << "*";
cout << endl << endl;
return 0;
}