<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 李阿昀 閱讀(394) 評論(0)  編輯  收藏 所屬分類: C Primer Plus 復習題與編程練習
    主站蜘蛛池模板: 一级毛片在线观看免费| 激情吃奶吻胸免费视频xxxx| 国产日韩AV免费无码一区二区 | 色猫咪免费人成网站在线观看 | 亚洲精品国产成人影院| 国产午夜亚洲精品不卡免下载| 狠狠久久永久免费观看| 亚洲欧美日韩国产成人| 日韩成人免费在线| 国产AV无码专区亚洲AV琪琪| 亚洲AⅤ无码一区二区三区在线| 亚洲国产美女精品久久久久∴| 久久精品国产亚洲av麻豆蜜芽| 国产精品入口麻豆免费观看| 亚洲一区二区三区播放在线| 四虎影院免费在线播放| 男人的天堂av亚洲一区2区| 亚洲AV成人潮喷综合网| 国产免费播放一区二区| 国产AV无码专区亚洲AVJULIA| 9277手机在线视频观看免费| 麻豆狠色伊人亚洲综合网站| 国产成人免费a在线资源| 菠萝菠萝蜜在线免费视频| 中文字幕亚洲综合久久菠萝蜜| 久久久久国产精品免费看| 亚洲另类自拍丝袜第1页| 成人永久福利免费观看| 精品国产福利尤物免费 | 亚洲性69影院在线观看| 在线jlzzjlzz免费播放| 一级毛片免费不卡| 亚洲黄色在线网站| 日韩电影免费观看| 亚洲自偷自偷在线成人网站传媒 | 我们的2018在线观看免费高清| 亚洲色欲啪啪久久WWW综合网| 亚洲第一视频在线观看免费| 色欲A∨无码蜜臀AV免费播| 亚洲精品欧美综合四区| 久久亚洲精品中文字幕三区|