程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> 關於C語言 >> 《C和指針》章節後編程練習解答參考——第10章,《c和指針》第10章

《C和指針》章節後編程練習解答參考——第10章,《c和指針》第10章

編輯:關於C語言

《C和指針》章節後編程練習解答參考——第10章,《c和指針》第10章


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 }

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved