<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    BeautifulMan

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      16 隨筆 :: 0 文章 :: 0 評論 :: 0 Trackbacks
    第2章 C語言概述
    復習題
    1、如何稱呼C程序的基本模塊?
    答:它們被稱為函數。
    2、什么是語法錯誤?給出它的一個英語例子和C語言例子。 
    答:C的語法錯誤是指把正確的C符號放在了錯誤的位置。這是英語中的一個例子:"Me speak English good.";這是C語言的一個例子:printf "Where are the parentheses?";
    3、什么是語義錯誤?給出它的一個英語例子和C語言例子。
    答:語義錯誤就是在意思上的錯誤。這是英語中的一個例子:"The sentence is excellent Italian.";這是C語言中的一個例子:thrice_n = 3 + n;
    4、Indiana Sloth 已經編好了下面的程序,并想征求你的意見。請幫助他評定。
    1 include studio.h
    int main{void/*該程序可顯示出一年中有多少周/*
    3 (
    4 int s

    6 s: = 56;
    7 print(There are s weeks in a year.);
    8 return 0;
    答:第1行:以一個#開始,拼寫出文件名stdio.h,然后把文件名放在一對尖括號中。
         第2行:使用(),而不是使用{};使用*/來結束注釋,而不是使用/*。
         第3行:使用{,而不是(。
         第4行:使用分號來結束語句。
         第5行:Indiana使這一行(空白行)正確!
         第6行:使用=,而不是使用:=進行賦值(顯然,Indiana 了解一些Pascal)。每年有52周而不是56周。
         第7行:應該是printf("There are %d weeks in a year.\n",s);
         第9行:源程序沒有第9行,但是應該有,它應該包含一個結束花括號}。
    在進行這些修改之后,代碼如下:
    1 #include<stdio.h>
    int main(void/*該程序可顯示出一年中有多少周/*
    3 {
    4 int s;

    6 s = 52;
    7 printf("There are %d weeks in a year.\n",s);
    8 return 0;
    9 }
    5、假設下面的每一個例子都是某個完整程序的一部分,它們每個將輸出什么結果?
    a.printf("Baa Baa Black Sheep.");
       printf("Have you any wool?\n");
    b.printf("Begone!\n0 creature of lard!");
    c.printf("What?\nNo/nBonzo?\n");
    d.int num;

      num = 2;
      printf("%d + %d = %d",num,num,num + num);
    答:a.Baa Baa Black Sheep.Have you any wool?(注意:在句號之后沒有空格。)
         b.Begone!
            0 creature of lard!(注意光標仍留在第2行結束處。)
         c.What?
            No/nBonzo?(注意斜線符號”/“沒有反斜線符號”\“所具有的作用,它只是簡單地作為斜線符號被打印出來。)
         d.2 + 2 = 4
    6、下面哪幾個是C的關鍵字?main,int,function,char,=
    答:int,char(注意main只是一個函數名,函數是C中的一個技術術語。=是一個運算符)
    7、如何以下面的格式輸出words和lines的值:"There were 3020 words and 350 lines"?這里,3020和350代表兩個變量的值。
    答: 
     1 #include <stdio.h>
     2
     int main(void)
     3 {
     4     int num1,num2;
     5     num1 = 3020;
     6     num2 = 350;
     7 
     8     printf("There were %d words and %d lines\n",num1,num2);
     9     return 0;
    10 }
    8、考慮下面的程序:
     1 #include <stdio.h>
     2 int main(void)
     3 {
     4     int a, b;
     5 
     6     a = 5;
     7     b = 2; /*第7行*/
     8     b = a; /*第8行*/
     9     a = b; /*第9行*/
    10     printf("%d %d\n", b, a);
    11     return 0;
    12 }
    請問在第7行、第8行和第9行之后程序的狀態分別是什么?
    答:第7行之后,a為5,b為2。第8行之后,a為5,b為5。第9行之后,a為5,b為5。
    編程練習(新手初學,僅供參考!!!)
    1、
    1 #include <stdio.h>
    2 int main(void)
    3 {
    4     printf("Li Ayun\n");
    5     printf("Li\nAyun\n");
    6     printf("Li ");
    7     printf("Ayun\n");
    8     return 0;
    9 }
    2、
    1 #include <stdio.h>
    2 int main(void)
    3 {
    4     printf("My name is Li Ayun!\n");
    5     printf("I live in BeiJing now!\n");
    6     return 0;
    7 }
    3、
    1 #include <stdio.h>
    2 int main(void)
    3 {
    4     int age;
    5     age = 23;
    6     printf("age = %d, days = %d\n", age, age * 365);
    7     return 0;
    8 }
    4、
     1 #include <stdio.h>
     2 void show(void);
     3 void end(void);
     4 int main(void)
     5 {
     6     show();
     7     show();
     8     show();
     9     end();
    10     return 0;
    11 }
    12 void show(void)
    13 {
    14    printf("For he's a jolly good fellow!\n");
    15 }
    16 void end(void)
    17 {
    18     printf("Which nobody can deny!\n");
    19 }
    5、
    1 #include <stdio.h>
    2 int main(void)
    3 {
    4     int toes;
    5     toes = 10;
    6 
    7     printf("toes = %d\ntoes + toes = %d\ntoes * toes = %d", toes, toes + toes, toes * toes);
    8     return 0;
    9 }
    6、
     1 #include <stdio.h>
     2 void showSmile(void);
     3 int main(void)
     4 {
     5     showSmile();
     6     showSmile();
     7     showSmile();
     8     printf("\n");
     9     showSmile();
    10     showSmile();
    11     printf("\n");
    12     showSmile();
    13     return 0;
    14 }
    15 void showSmile(void)
    16 {
    17     printf("Smile!");
    18 }
    7、
     1 #include <stdio.h>
     2 void one_three(void);
     3 void two(void);
     4 int main(void)
     5 {
     6     printf("starting now:\n");
     7     one_three();
     8     two();
     9     printf("done!");
    10     return 0;
    11 }
    12 void one_three(void)
    13 {
    14     printf("one\n");
    15 }
    16 void two(void)
    17 {
    18     printf("two\nthree\n");
    19 }

    posted on 2015-10-28 20:22 李阿昀 閱讀(392) 評論(0)  編輯  收藏 所屬分類: C Primer Plus 復習題與編程練習
    主站蜘蛛池模板: 在线观看免费人成视频色| 亚洲一区二区三区免费视频| 免费看少妇作爱视频| 亚洲视频一区二区三区四区| 日本三级2019在线观看免费| 亚洲成a人片在线观看中文!!!| 亚洲精品在线免费观看视频| 亚洲精品视频在线观看免费| 91网站免费观看| 亚洲H在线播放在线观看H| 毛片a级毛片免费观看品善网| 亚洲精品无码人妻无码| 国产成人免费全部网站| 人妻无码中文字幕免费视频蜜桃| 亚洲欧洲久久av| 日本一道本不卡免费| 91久久亚洲国产成人精品性色| 日韩在线播放全免费| 亚洲色成人网站WWW永久四虎 | 日日麻批免费40分钟无码| 亚洲福利在线观看| 国产免费不卡v片在线观看| 亚洲av片在线观看| 中文字幕专区在线亚洲| 无码少妇精品一区二区免费动态| 亚洲成人在线免费观看| 永久久久免费浮力影院| CAOPORN国产精品免费视频| 久久久久久a亚洲欧洲AV| 久热中文字幕在线精品免费| 亚洲精华液一二三产区| 337p日本欧洲亚洲大胆裸体艺术 | 久久精品亚洲一区二区三区浴池 | 亚洲Av无码乱码在线znlu| 成全视频免费观看在线看| 亚洲伊人久久大香线蕉啊| 午夜国产大片免费观看| 香港a毛片免费观看 | 亚洲美女在线国产| 2021国产精品成人免费视频| 三年片在线观看免费观看大全中国 |