Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include<stdlib.h>
- struct canbo{
- char tenCB[30];
- int namsinh;
- float luong;
- } a[100];
- int n;
- void nhap() {
- printf("Nhap so luong can bo: ");
- scanf("%d", &n);
- int i;
- for (i = 0; i < n; i++) {
- printf("Nhap ten can bo: ");
- fflush(stdin);
- gets(a[i].tenCB);
- printf("Nhap nam sinh cua can bo: ");
- scanf("%d", &a[i].namsinh);
- printf("Nhap luong cua can bo:(Don vi trieu dong): ");
- scanf("%f", &a[i].luong);
- }
- }
- void hienthi() {
- printf("Danh sach cac can bo: ");
- int i;
- for (i = 0; i < n; i++) {
- printf("%s\t%d\t%f\n", a[i].tenCB, a[i].namsinh,a[i].luong);
- fflush(stdout);
- }
- }
- void cau3() {
- printf("danh sach can bo co luong < 5 trieu: ");
- int i;
- for (i = 0; i < n; i++)
- if (a[i].luong < 5.0)
- {
- printf("%s\t%d\t%f\n", a[i].tenCB, a[i].namsinh,a[i].luong);
- fflush(stdout);
- }
- }
- void cau4() {
- printf("danh sach can bo co nam sinh truoc nam 1980 ");
- int i;
- for (i = 0; i < n; i++)
- if (a[i].namsinh < 1980)
- {
- printf("%s\t%d\t%f\n", a[i].tenCB, a[i].namsinh,a[i].luong);
- fflush(stdout);
- }
- }
- int main() {
- nhap();
- hienthi();
- cau3();
- cau4();
- }
Add Comment
Please, Sign In to add comment