#include<conio.h> #include<stdlib.h> #include<stdio.h> #include<math.h> #include<string.h> struct nhanvien { char hoten[30]; char chucvu[50]; float chiso; float luong; }; int main() { nhanvien nv[200]; int n,i; printf("nhap so luong nhan vien :"); scanf("%d",&n); printf("nhap thong tin cho tung nhan vien \n"); for(i=0;i<n;i++) { printf("nhap nhan vien thu %d",i+1); printf("\nnhap ho va ten : "); fflush(stdin); gets(nv[i].hoten); do { fflush(stdin); printf("\nnhap chuc vu: "); fflush(stdin); gets(nv[i].chucvu); } while(strcmp(nv[i].chucvu,"gd")!=0 &&strcmp(nv[i].chucvu,"pgd")!=0); printf("\nnhap chi so luong : "); fflush(stdin); scanf("%f",&nv[i].chiso); //tinh luong if(strcmp(nv[i].chucvu,"gd")) { nv[i].luong=nv[i].chiso*1500000+500000; } else if(strcmp(nv[i].chucvu,"pgd")) { nv[i].luong=nv[i].chiso*1500000+300000; } } printf("danh sach nhan vien sau khi nhap la "); i=1; printf("\nSTT ho va ten chuc vu chi so luong ky nhan\n"); for(i=0;i<n;i++) { printf("%d",i+1); printf("%15s ",nv[i].hoten); printf("%15s",nv[i].chucvu); printf("%20.2f",nv[i].chiso); printf("%15.0f",nv[i].luong); printf("\n"); } getch() ; }
Tags:
lập trình c