Objective-C 程式設計(第六版)第四章習題答案

來源:互聯網
上載者:User

標籤:style   blog   color   io   ar   2014   div   sp   問題   

1.   非法常量

      0x10.5    0X0G1    98.7U    17777s    0996    1.2Fe-7    15,000    .

2.

     //只需要列出運算式就可以                int F = 27;       //設定F為華氏溫度,賦值 27        float C ;           //設定C為攝氏溫度,類型為浮點類型                C = (F-32)/1.8;        NSLog(@"%.1f",C);     // %.1f 保留一位小數就可以     //輸出結果       2014-09-17 14:58:48.259 prog1[6058:303] -2.8       Program ended with exit code: 0

3.    輸出結果為 d .

4.    

        float x = 2.55 ,  result ;                result = 3 * (x * x * x) - 5 * (x * x) + 6 ;                NSLog(@"result is %f",result);       //結果如下      2014-09-17 15:11:11.064 prog1[6196:303] result is 23.231621

5.

        //不知道這道題考的是什麼 列出運算式過了得了        double result;                result = (3.31e-8 + 2.01e-7) / (7.16e-6 + 2.01e-8);                NSLog(@"result is %e",result);                //輸出結果        2014-09-17 15:29:31.547 prog1[6274:303] result is 3.260400e-02        Program ended with exit code: 0

6.

//-------------interface部分-----------@interface Complex : NSObject- (void) setReal: (double) a;            //設定實數- (void) setImaginary: (double) b;    //設定虛數- (void) print;                                 //列印結果- (double) real;- (double) imaginary;@end//--------------implementation部分----------------@implementation Complex{    double real;    double imaginary;}- (void) setReal: (double) a{    real = a;}- (void) setImaginary: (double) b{    imaginary = b;}- (void) print{    NSLog(@"The complex is %.f + %.fi", real, imaginary);}- (double) real{    return real;}- (double) imaginary{    return imaginary;}@end//----------------program部分-------------int main(int argc, const char * argv[]){    @autoreleasepool {        Complex * newComplex = [[Complex alloc]init];                [newComplex setReal:11];        [newComplex setImaginary:22];
//下面兩個方法都可以 ,分別測試 print方法和 real,imaginary方法;(應題目要求) [newComplex print];

  //      NSLog(@"The complex is %.f + %.fi",[newComplex real],[newComplex imaginary]);

           }    return 0;}//結果如下   2014-09-17 17:27:59.830 prog1[6678:303] The complex is 11 + 22i   Program ended with exit code: 0

7.

手機出問題了  弄手機先

 

Objective-C 程式設計(第六版)第四章習題答案

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.