Professional Documents
Culture Documents
WS7 - Nguyễn Văn Nhật Linh - DE160328 - 1706
WS7 - Nguyễn Văn Nhật Linh - DE160328 - 1706
WS7 - Nguyễn Văn Nhật Linh - DE160328 - 1706
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
char Chon_Chuong_Trinh()
int c;
printf("5-Thoat\n");
fflush(stdin);
scanf("%c", &c);
return c;
void Them_NV (char Ma_ID[][8], char Ten[][21], double Luong[],double Tro_Cap[], int *pn)
{
char ts[21];
double g;
int i, TT;
do {
fflush(stdin);
scanf("%8[^\n]", ts);
TT = 1;
if (strcmp(ts,Ma_ID[i]) == 0)
TT = 0;
i = *pn - 1;
} while (!TT);
strcpy(Ma_ID[*pn], ts);
do {
fflush(stdin);
scanf("%20[^\n]", ts);
TT = 1;
if (strcmp(ts,Ma_ID[i]) == 0)
TT = 0;
i = *pn - 1;
}
} while (!TT);
strcpy(Ten[*pn], ts);
printf("Luong : ");
scanf("%lf", &g);
Luong[*pn] = g;
scanf("%lf", &g);
Tro_Cap[*pn] = g;
(*pn)++;
system("pause");
system("cls");
void Tim_NV(char Ma_ID[][8], char Ten[][21], double Luong[],double Tro_Cap[], int *pn)
int i;
char nv[21];
fflush(stdin);
scanf("%20[^\n]", &nv);
int j;
if (ptr != " ") printf("Ket qua tim kiem :[%d] := Ma ID:%8s|Ten Nhan Vien:%20s|
Luong:%3.3lf|Tro Cap:%3.3lf \n"
,i ,
Ma_ID[i] , Ten[i] , Luong[i] , Tro_Cap[i]);
system("pause");
system("cls");
void Xoa_NV(char Ma_ID[][8], char Ten[][21], double Luong[],double Tro_Cap[], int *pn)
int i,j;
char xoa[8];
fflush(stdin);
scanf("%8[^\n]", &xoa);
if (strcmp(Ma_ID[i], xoa) == 0)
strcpy(Ten[i-1], Ten[i]);
strcpy(Ma_ID[i-1], Ma_ID[i]);
Tro_Cap[i-1] = Tro_Cap[i];
(*pn)--;
printf("Hoan thanh!\n\n");
}
system("pause");
system("cls");
void IN_Giam_dam(char Ma_ID[][8], char Ten[][21], double Luong[],double Tro_Cap[], int *pn)
int i, j;
char t[21];
strcpy(t, Ten[j]);
strcpy(Ten[j], Ten[j-1]);
strcpy(Ten[j-1], t);
char tu[8];
strcpy(tu, Ma_ID[j]);
strcpy(Ma_ID[j], Ma_ID[j-1]);
strcpy(Ma_ID[j-1], tu);
double tg = Luong[j];
Luong[j]=Luong[j-1];
Luong[j-1]=tg;
double tb = Tro_Cap[j];
Tro_Cap[j]=Tro_Cap[j-1];
Tro_Cap[j-1]=tb;
if (*pn)printf("Hoan Thanh!\n\n");
system("pause");
system("cls");
void Ket_Thuc()
printf("Thank you\n");
main()
char Chon;
char Ma_ID[MAXN][8],Ten[MAXN][21];
int n = 0;
do
Chon = Chon_Chuong_Trinh();
switch(Chon)
case '1':
case '2':
break;
case '3':
break;
case '4':
break;
case '5':Ket_Thuc();break;
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
char Chon_Chuong_Trinh()
int c;
printf("5-Thoat\n");
fflush(stdin);
scanf("%c", &c);
return c;
void Them_NV (char Ma_ID[][8], char Ten[][21], double Luong[],double Tro_Cap[], int *pn)
char ts[21];
double g;
int i, TT;
do {
fflush(stdin);
scanf("%8[^\n]", ts);
TT = 1;
if (strcmp(ts,Ma_ID[i]) == 0)
{
printf("Ma ID da ton tai!Vui long nhap lai!\n");
TT = 0;
i = *pn - 1;
} while (!TT);
strcpy(Ma_ID[*pn], ts);
do {
fflush(stdin);
scanf("%20[^\n]", ts);
TT = 1;
if (strcmp(ts,Ma_ID[i]) == 0)
TT = 0;
i = *pn - 1;
} while (!TT);
strcpy(Ten[*pn], ts);
printf("Luong : ");
scanf("%lf", &g);
Luong[*pn] = g;
scanf("%lf", &g);
Tro_Cap[*pn] = g;
(*pn)++;
system("pause");
system("cls");
void Tim_NV(char Ma_ID[][8], char Ten[][21], double Luong[],double Tro_Cap[], int *pn)
int i;
char nv[21];
fflush(stdin);
scanf("%20[^\n]", &nv);
int j;
if (ptr != " ") printf("Ket qua tim kiem :[%d] := Ma ID:%8s|Ten Nhan Vien:%20s|
Luong:%3.3lf|Tro Cap:%3.3lf \n"
,i ,
Ma_ID[i] , Ten[i] , Luong[i] , Tro_Cap[i]);
system("pause");
system("cls");
void Xoa_NV(char Ma_ID[][8], char Ten[][21], double Luong[],double Tro_Cap[], int *pn)
int i,j;
fflush(stdin);
scanf("%8[^\n]", &xoa);
if (strcmp(Ma_ID[i], xoa) == 0)
strcpy(Ten[i-1], Ten[i]);
strcpy(Ma_ID[i-1], Ma_ID[i]);
Tro_Cap[i-1] = Tro_Cap[i];
(*pn)--;
printf("Hoan thanh!\n\n");
system("pause");
system("cls");
void IN_Giam_dam(char Ma_ID[][8], char Ten[][21], double Luong[],double Tro_Cap[], int *pn)
int i, j;
{
char t[21];
strcpy(t, Ten[j]);
strcpy(Ten[j], Ten[j-1]);
strcpy(Ten[j-1], t);
char tu[8];
strcpy(tu, Ma_ID[j]);
strcpy(Ma_ID[j], Ma_ID[j-1]);
strcpy(Ma_ID[j-1], tu);
double tg = Luong[j];
Luong[j]=Luong[j-1];
Luong[j-1]=tg;
double tb = Tro_Cap[j];
Tro_Cap[j]=Tro_Cap[j-1];
Tro_Cap[j-1]=tb;
if (*pn)printf("Hoan Thanh!\n\n");
system("pause");
system("cls");
void Ket_Thuc()
printf("Thank you\n");
}
main()
char Chon;
char Ma_ID[MAXN][8],Ten[MAXN][21];
int n = 0;
do
Chon = Chon_Chuong_Trinh();
switch(Chon)
case '1':
break;
case '2':
break;
case '3':
break;
case '4':
break;
case '5':Ket_Thuc();break;