欧美色欧美亚洲高清在线观看,国产特黄特色a级在线视频,国产一区视频一区欧美,亚洲成a 人在线观看中文

  1. <ul id="fwlom"></ul>

    <object id="fwlom"></object>

    <span id="fwlom"></span><dfn id="fwlom"></dfn>

      <object id="fwlom"></object>

      C語言程序設計教程 課后習題參考答案

      時間:2019-05-12 19:40:29下載本文作者:會員上傳
      簡介:寫寫幫文庫小編為你整理了多篇相關的《C語言程序設計教程 課后習題參考答案》,但愿對你工作學習有幫助,當然你在寫寫幫文庫還可以找到更多《C語言程序設計教程 課后習題參考答案》。

      第一篇:C語言程序設計教程 課后習題參考答案

      《C語言程序設計教程》

      課后習題參考答案

      習題1 1.(1)編譯、鏈接

      .exe(2)函數(shù)

      主函數(shù)(或main函數(shù))(3)編輯

      編譯

      鏈接 2.(1)-(5):DDBBC(6)-(10):ABBBC 3.(1)答:C語言簡潔、緊湊,使用方便、靈活;C語言是高級語言,同時具備了低級語言的特征;C語言是結構化程序設計語言,具有結構化的程序控制語句;C語言有各種各樣的數(shù)據(jù)類型;C語言可移植性好;生成目標代碼質量高,程序執(zhí)行效率高。

      (2)編輯、編譯、鏈接、執(zhí)行

      (3)一個C程序由一或多個函數(shù)組成,一函數(shù)若干條語句構成,每條語句的末尾必須以分號結束。

      (4)標識符,關鍵字,運算符,分隔符,常量,注釋符等 4.從鍵盤輸入一個雙精度小數(shù),打印出它的余弦值。#include #include main(){ double x;scanf(“%lf”, &x);printf(“%lfn”, cos(x));}

      第2章 1.(1)BDE、ACFG(2)D(3)C(4)C

      2.(1)錯(2)錯(3)錯(4)對(5)錯 3.(1)a=3,b=-27(2)a=11,b=6,c=6(3)3(4)1 0 1 0 1 1 0(5)-9 9 8(6)1)20 2)8 3)70 4)0 5)0 6)0 4.(1)

      #include main(){ double r, h ,v;r = 2.5;h = 3.5;v = 3.14*r*r*h;printf(“v=%lfn”, v);}(2)#include main(){ char ch;ch = getchar();printf(“%cn”, ch + 32);}(3)#include main(){ printf(“

      *n”);printf(“

      ***n”);printf(“ *****n”);printf(“*******n”);}(4)#include main(){ double x;scanf(“%lf”, &x);printf(“%d , %lfn”,(int)x, x –(int)x);}(5)#include main(){ double a=3, b=5;double result =(-2 * a +(4*a – b)/(2*a + b))/((a32);}

      第4章 1.(1)-(5):CAACA 2.(1)BBB(2)AAABBBCCC(3)end(4)d=20(5)s=2,t=3(6)first

      third(7)y=0 y=5 y=10 y=5 3.(1)y=?A? && ch<=?Z?

      ch>=?a?&&ch<=?z?

      ch = ch-32(3)x>2&&x<=10

      x>-1&&x<=2(4)t=x;x=y;y=t;4.(1)#include main(){ int x, y , z, t;scanf(“%d%d%d”, &x, &y, &z);

      if(x>y){ t=x;x=y;y=t;} if(x > z){ t = x;x = z;z= t;} if(y > z){ t = y;y= z;z = t;} printf(“%d %d %dn”, x, y ,z);}(2)#include main(){ int score;scanf(“%d”, &score);

      if(score < 0 || score > 100)

      printf(“成績不合理n”);

      else if(score>=90)

      printf(“優(yōu)秀n”);

      else if(score>=80)

      printf(“良好n”);

      else if(score >= 70)

      printf(“中等n”);

      else if(score >= 60)

      printf(“及格n”);

      else

      printf(“不及格n”);}(3)#include main(){ int n;int g,s,b,q;//各位上的數(shù)值

      scanf(“%d”, &n);

      g = n%10;//個位

      s = n/10%10;//十位

      b = n/100%10;//百位

      q = n/1000%10;//千位

      if(n < 10)//一位數(shù)

      {

      printf(“%dn”, 1);//位數(shù)

      printf(“%dn”, g);//各位上的數(shù)值

      } else if(n < 100)//兩位數(shù)

      {

      printf(“%dn”, 2);//位數(shù)

      printf(“%d %dn”, g,s);} else if(n < 1000)//三位數(shù)

      {

      printf(“%dn”, 3);//位數(shù)

      printf(“%d %d %dn”, g, s, b);

      } else if(n < 10000)//四位數(shù)

      {

      printf(“%dn”, 4);//位數(shù)

      printf(“%d %d %d %dn”, g, s, b, q);

      } }(4)#include main(){ int n;scanf(“%d”, &n);

      if(n % 3==0 && n%5==0 && n%7==0)

      printf(“能同時被3、5、7整除n”);

      else if(n%3==0 && n%5==0)

      printf(“能被3和5整除n”);

      else if(n%3==0 && n%7==0)

      printf(“能被3和7整除n”);

      else if(n%5==0 && n%7==0)

      printf(“能被5和7整除n”);

      else if(n%3==0 || n%5==0 || n%7==0){

      if(n%3==0)

      printf(“能被3整除n”);

      else if(n%5==0)

      printf(“能被5整除n”);

      else

      printf(“能被7整除n”);

      } else

      printf(“不能被3、5、7中任一個數(shù)整除n”);}(5)#include main(){ int

      carType;//車型。1代表夏利;2代表富康;3代表桑塔納

      double xiali = 2.1;//每公里價格 double fukang = 2.4;double sangtana = 2.7;double distance;//距離

      double totalMoney;//總的收費

      printf(“請輸入您乘坐的車型:1代表夏利;2代表富康;3代表桑塔納:”);scanf(“%d”, &carType);printf(“請輸入您乘車的總路程:”);scanf(“%lf”, &distance);if(carType == 1)//夏利

      {

      if(distance < 3)

      totalMoney = 7.0;

      else

      totalMoney = 7 + xiali *(distance – 3);} else if(carType == 2)//富康

      {

      if(distance < 3)

      totalMoney = 8.0;

      else

      totalMoney = 8 + fukang *(distance – 3);} else if(carType == 3)//富康

      {

      if(distance < 3)

      totalMoney = 9.0;

      else

      totalMoney = 9 + sangtana *(distance – 3);}

      printf(“(四舍五入)您的車費為:%.0lfn”, totalMoney);}(6)#include main(){ double a, b, c;scanf(“%lf%lf%lf”, &a, &b, &c);

      if(a+b>c && b+c>a && c+a>b){

      if(a==b && b==c)

      printf(“等邊三角形n”);

      else if(a==b || b== c || c==a)

      printf(“等腰三角形n”);

      else

      printf(“一般三角形n”);

      } else

      printf(“不能構成三角形n”);}

      第5章

      1.(1)C(2)C(3)K=36(4)C(5)B 2.(1)3次

      (2)x>=1 && x<=10 || x>=200&&x<210(3)e == 0(4)6次(5)10 3.(1)20,10(2)16,0(3)7BAB4BAB1BC(4)ABABABC(5)****** ****** ******

      ****** 4.(1)a!= b

      (2)n / 10(3)scanf(“%d”, &a);

      5.(3)行

      int fac = 1, sum = 0;6.(1)#include main(){ char ch;int alpha=0, space=0, digit=0, other=0;while((ch=getchar())!= ?n?)

      {

      if(ch>=?A?&&ch<=?Z? || ch>=?a?&&ch<=?z?)

      alpha++;

      else if(ch>=?0? && ch<=?9?)

      digit++;

      else if(? ? == ch)

      space++;

      else

      other++;} printf(“%d %d %d %dn”, alpha, digit, space, other);}(2)#include main(){ int m20, m10;for(m20=1;m20<5;m20++){

      for(m10 = 1;m10<10;m10++)

      if(20*m20+10*m10 == 100)

      printf(“%d, %dn”, m20, m10);} }(3)#include main(){ int x, y, z;for(x=0;x<10;x++)

      for(y=0;y<10;y++)

      for(z=0;z<10;z++)

      if(x*100+y*10+z + y*100+z*10+z == 532)

      printf(“%d %d %dn”, x, y, z);}(4)#include main(){ int row, spaceCount,starCount;int n;scanf(“%d”, &n);

      for(row = 1;row <= n;++row){

      for(spaceCount = 1;spaceCount <= n1;++starCount)

      printf(“*”);//打印出某行上的所有星號

      printf(“n”);//換行

      } //打印下半部分

      for(row=1;row

      for(spaceCount = 1;spaceCount <= row;++ spaceCount)

      printf(“ ”);//打印出某行上星號前的空格

      for(starCount = 1;starCount <= 2*(n-row)byear;if(nmonth

      age--;else if(nmonth == bmonth && nday>bday)

      age--;return age;}

      (4)

      #include int sum(int n);main(){ int n,s;scanf(“%d”, &n);s = sum(n);printf(“s=%dn”, s);}

      int sum(int n){ int s=0;while(n){

      s += n % 10;

      n /= 10;} return s;}

      (5)

      #include double sumfac(int n);main(){ int n;scanf(“%d”, &n);printf(“%.0lfn”, sumfac(n));} double sumfac(int n){ double f=1.0, s = 0.0;

      int i;for(i=1;i<=n;i++){

      f *= i;

      s += f;} return f;}

      (6)

      #include int gcd(int m , int n);main(){ int m, n;scanf(“%d%d”, &m, &n);printf(“%dn”, gcd(m ,n));} int gcd(int m, int n){ int t,r;if(m < n){ t = m;m= n;n = t;}

      r = m % n;while(r){

      m = n;

      n = r;

      r = m % n;} return n;}

      (7)

      #include int gcd(int m , int n);int lcm(int m, int n);main(){ int m, n;scanf(“%d%d”, &m, &n);printf(“%dn”, lcm(m ,n));} int gcd(int m, int n){ int t,r;if(m < n){ t = m;m= n;n = t;}

      r = m % n;while(r){

      m = n;

      n = r;

      r = m % n;} return n;}

      int lcm(int m, int n){ return m*n/gcd(m,n);}

      (8)

      #include double mypower(double x, int y);main(){ double x;

      int y;scanf(“%lf%d”, &x, &y);printf(“%lfn”, mypower(x,y));} double mypower(double x, int y){ int i;double f=1.0;for(i=1;i<=y;i++)

      f *= x;return f;}

      第7章 1.(1)6(2)5(3)不能

      (4)int a[3][2]={{1,2}, {3,4}, {5,6} };(5)6 9(6)abc G 2.(1)

      #include

      void reverse(int a[ ], int n);

      int main()

      {

      int array[10]={0};

      int i;

      printf(“請輸入10個整數(shù):”);

      for(i=0;i<10;i++)

      scanf(“%d”, &array[i]);

      reverse(array, 10);//調用函數(shù)逆序存儲數(shù)組中的數(shù)據(jù)

      printf(“逆序后的元素為:n”);

      for(i=0;i<10;i++)

      printf(“%5d”, array[i]);

      printf(“n”);

      return 0;

      }

      void reverse(int a[ ], int n)

      {

      int i;

      int tmp;

      for(i=0;i

      {

      tmp = a[i];a[i] = a[n-i-1];

      }

      }

      (2)

      #include #include void reverseStr(char str[ ]);main(){ char s[100];gets(s);reverseStr(s);puts(s);}

      void reverseStr(char str[ ]){ int i,j;char t;i=0;j=strlen(str)-1;while(i < j){

      t = str[i];

      a[n-i-1] = tmp;

      str[i] = str[j];

      str[j] = t;

      i++;

      j--;} }

      (3)

      #include int copyTo(int s1[], int n, int s2[ ]);main(){ int s1[10], s2[10];int i,count;for(i=0;i<10;i++)

      scanf(“%d”, &s1[i]);count = copyTo(s1, 10, s2);for(i=0;i

      printf(“%d ”, s2[i]);printf(“n”);}

      int copyTo(int s1[], int n, int s2[ ]){ int i, j=0;for(i=0;i

      if(s1[i] % 2)

      s2[j++] = s1[i];} return j;}

      (4)

      #include void copyToStr(char str1[ ], char str2[ ]);main(){ char s1[100], s2[100];gets(s1);copyToStr(s1, s2);puts(s2);} void copyToStr(char str1[ ], char str2[ ]){ int i=0,j=0;while(str1[i]!= '