《C和指针》章节后编程练习解答参考——第10章

时间:2022-03-08 20:15:52

10.1

 #include <stdio.h>

 typedef struct
{
unsigned char QuHao[];
unsigned char Exchange[];
unsigned char StnNum[];
}TelphoneNumber; typedef struct
{
unsigned char date[];
unsigned char time[];
TelphoneNumber UserTelphone;
TelphoneNumber CallTelphone;
TelphoneNumber PayTelphone;
}Telphone_Call; int main (void)
{ getchar();
return ;
}

10.2

 #include <stdio.h>

 #define    NAMELENGTH    21
#define ADDRLENGTH 41
#define MODLLENGTH 21
#define NAMEOFBANKLEN 21 typedef struct
{
float ManufacturerSuggestedRetailPrice;
float ActualSellingPrice;
float SalesTax;
float LicensingFee;
}CashSale; typedef struct
{
float ManufacturerSuggestedRetailPrice;
float ActualSellingPrice;
float DownPayment;
float SecurityDeposit;
float MonthlyPayment;
int LeaseTerm;
}Rent; typedef struct
{
float ManufacturerSuggestedRetailPrice;
float ActualSellingPrice;
float SalesTax;
float LicensingFee;
float DownPayment;
int LoanDuration;
float InterestRate;
float MonthlyPayment;
char NameOfBank[NAMEOFBANKLEN];
}LoanSale; typedef struct
{
char CustomerName[NAMELENGTH];
char CustomerAddr[ADDRLENGTH];
char Model[MODLLENGTH];
CashSale CashSal;
Rent RentSal;
LoanSale LoanSal;
}SaleRecord; int main (void)
{ getchar();
return ;
}

10.3

 #include <stdio.h>

 typedef struct
{
unsigned int dst_reg : ; //0-2
unsigned int dst_mode : ; //3-5
unsigned int opcode : ; //6-15
}SingleOperat; typedef struct
{
unsigned int dst_reg : ; //0-2
unsigned int dst_mode : ; //3-5
unsigned int src_reg : ; //6-8
unsigned int src_mode : ; //9-11
unsigned int opcode : ; //12-15
}DoubleOperat; typedef struct
{
unsigned int offset : ; //0-7
unsigned int opcode : ; //8-15
}Branch; typedef struct
{
unsigned int dst_reg : ; //0-2
unsigned int dst_mode : ; //3-5
unsigned int src_reg : ; //6-8
unsigned int opcode : ; //9-15
}RegistSrc; typedef struct
{
unsigned int opcode :; //0-15
}MiscCmd; typedef struct
{
unsigned short addr;
SingleOperat sgl_op;
DoubleOperat dbl_op;
Branch branch;
RegistSrc reg_src;
MiscCmd misc;
}machine_inst; machine_inst x; int main (void)
{ getchar();
return ;
}