//--------------------------------------------------------- // ÇÁ·Î±×·¥: Á÷¿ø ±Þ¿© ÁÖ´ÜÀ§ °è»ê ÇÁ·Î±×·¥ // ³¯ Â¥: 2004-9-21 // ÆÄ ÀÏ: cash.cpp // ÇÔ ¼ö: // ¼³ ¸í: ±Þ¿©¸¦ °è»êÇØ ³»ÀÚ. // Àú ÀÚ: ±èÁø¼ö // ȯ °æ: p2.4c ram 1g winxp bcc5.5 // ±â Ÿ: // ¼ö Á¤: //--------------------------------------------------------- #include #include #define Continue (SelNum=Display(EmpNum)) != 3 #define Success (tempEmp = EmpInput()).EmpID != NULL #define ID 1 #define Hours 2 #define Wage 3 #define TaxRate 4 struct DataEmp { short EmpID; short EmpWorkHours; short EmpWage; short EmpTaxRate; }; // Employee¸¦ ÀúÀåÇϱâ À§ÇÑ ±¸Á¶Ã¼ short Display(short); void Display(DataEmp *,short); DataEmp EmpInput(); short GetValue(short); void Prompt(short); void main() { short EmpNum = 0,SelNum; DataEmp *Employee = NULL,*temp = NULL,tempEmp; while(Continue) // 3Àº ÇÁ·Î±×·¥ Á¾·á { switch(SelNum) { case 1 : if(Success) // ÀԷ¹޾Ƽ­ ³Ñ¾î¿Â Employee ±¸Á¶Ã¼¿¡¼­ ID°¡ NULL ÀÌ ¾Æ´Ï¶ó¸é // Áï µ¥ÀÌÅ͸¦ °¡Áö°í ÀÖ´Ù¸é { EmpNum++; cout << "\n New Employee saved" ; temp = (DataEmp *)malloc((EmpNum-1)*sizeof(DataEmp)); if((EmpNum-1) != 0) { for(int i=0 ;i> "; cin >> SelNum; return (SelNum); } //--------------------------------------------------------- DataEmp EmpInput() { DataEmp RetData; short Num; RetData.EmpID = GetValue(ID); RetData.EmpWorkHours = GetValue(Hours); RetData.EmpWage = GetValue(Wage); RetData.EmpTaxRate = GetValue(TaxRate); return (RetData); } //--------------------------------------------------------- short GetValue(short num) { short RetNum; Prompt(num); cin >> RetNum; return(RetNum); } //--------------------------------------------------------- void Prompt(short num) { switch(num) { case ID : cout << "Enter Employee ID Number" << "\n>> "; break; case Hours :cout << "Enter Employee work hours" << "\n>> "; break; case Wage : cout << "Enter Employee wage rate" << "\n>> "; break; case TaxRate : cout << "Enter Employee tax rate" << "\n>> "; break; } } //--------------------------------------------------------- void Display(DataEmp *List,short num) { for(int i=0 ; i