• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

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

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

10.1

 

 1 #include <stdio.h>
 2 
 3 typedef struct 
 4 {
 5     unsigned char QuHao[5];
 6     unsigned char Exchange[10];
 7     unsigned char StnNum[10];
 8 }TelphoneNumber;
 9 
10 typedef struct 
11 {
12     unsigned char date[10];
13     unsigned char time[10];
14     TelphoneNumber    UserTelphone;
15     TelphoneNumber    CallTelphone;
16     TelphoneNumber    PayTelphone;
17 }Telphone_Call;
18 
19 int main (void)
20 {
21 
22     getchar();
23     return 0;
24 }

 

 

10.2

 

 1 #include <stdio.h>
 2 
 3 #define    NAMELENGTH    21
 4 #define    ADDRLENGTH    41
 5 #define    MODLLENGTH    21
 6 #define NAMEOFBANKLEN    21
 7 
 8 typedef struct
 9 {
10     float    ManufacturerSuggestedRetailPrice;
11     float    ActualSellingPrice;
12     float    SalesTax;
13     float    LicensingFee;
14 }CashSale;
15 
16 typedef struct
17 {
18     float    ManufacturerSuggestedRetailPrice;
19     float    ActualSellingPrice;
20     float    DownPayment;
21     float    SecurityDeposit;
22     float    MonthlyPayment;
23     int        LeaseTerm;
24 }Rent;
25 
26 typedef struct
27 {
28     float    ManufacturerSuggestedRetailPrice;
29     float    ActualSellingPrice;
30     float    SalesTax;
31     float    LicensingFee;
32     float    DownPayment;
33     int        LoanDuration;
34     float    InterestRate;
35     float    MonthlyPayment;
36     char    NameOfBank[NAMEOFBANKLEN];
37 }LoanSale;
38 
39 typedef struct
40 {
41     char    CustomerName[NAMELENGTH];
42     char    CustomerAddr[ADDRLENGTH];
43     char    Model[MODLLENGTH];
44     CashSale    CashSal;
45     Rent        RentSal;
46     LoanSale    LoanSal;
47 }SaleRecord;
48 
49 int main (void)
50 {
51 
52     getchar();
53     return 0;
54 }

 

 

10.3

 

 1 #include <stdio.h>
 2 
 3 typedef struct
 4 {
 5     unsigned int    dst_reg        : 3;    //0-2
 6     unsigned int    dst_mode    : 3;    //3-5
 7     unsigned int    opcode        : 10;    //6-15
 8 }SingleOperat;
 9 
10 typedef struct
11 {
12     unsigned int    dst_reg        : 3;    //0-2
13     unsigned int    dst_mode    : 3;    //3-5
14     unsigned int    src_reg        : 3;    //6-8
15     unsigned int    src_mode    : 3;    //9-11
16     unsigned int    opcode        : 4;    //12-15
17 }DoubleOperat;
18 
19 typedef struct
20 {
21     unsigned int    offset        : 8;    //0-7
22     unsigned int    opcode        : 8;    //8-15
23 }Branch;
24 
25 typedef struct
26 {
27     unsigned int    dst_reg        : 3;    //0-2
28     unsigned int    dst_mode    : 3;    //3-5
29     unsigned int    src_reg        : 3;    //6-8
30     unsigned int    opcode        : 7;    //9-15
31 }RegistSrc;
32 
33 typedef struct
34 {
35     unsigned int    opcode        :16;    //0-15
36 }MiscCmd;
37 
38 typedef struct
39 {
40     unsigned short    addr;
41     SingleOperat    sgl_op;
42     DoubleOperat    dbl_op;
43     Branch            branch;
44     RegistSrc        reg_src;
45     MiscCmd            misc;
46 }machine_inst;
47 
48 machine_inst    x;
49 
50 int main (void)
51 {
52 
53     getchar();
54     return 0;
55 }

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap