C Primer Plus 第六章 编程练习 1-8题
2017-03-09 20:01
357 查看
第一题
第二题
第三题
第四题
第五题
第六题
第七题
第八题
#include<stdio.h> int Nu = 26; int main(void) { char letters[Nu]; char EnterChar = 'a'; char EndChar = 'z'; int counts = 0; while(EnterChar != EndChar+1) { letters[counts] = EnterChar; ++counts; ++EnterChar; } printf("%s\n",letters); return 0; }
第二题
#include<stdio.h> const int Nu = 5; const char ShowChar = '$'; int main(void) { for(int i = 0 ; i < Nu ; ++i) { for(int j = 0 ; j <= i ; ++j) printf("%c",ShowChar); printf("\n"); } return 0; }
第三题
#include<stdio.h> const int ROWS = 6; int main(void) { char FirstChar = 'F'; for(int i = 0 ; i < ROWS ; ++i) { for(int j = 0 ; j <= i ; ++j) printf("%c",FirstChar-j); printf("\n"); } return 0; }
第四题
#include<stdio.h> const int ROWS = 5; int main(void) { char FirstChar = 'A'; for(int i = 1 ; i <= ROWS ; ++i) { for(int Space = 0 ; Space < ROWS-i ; ++Space) //First Loop To Space printf(" "); // My OptionSystem Looks Like Don't Support "\b",I Only Use " " Replace "\b".... for(int UpLetter = 0 ; UpLetter < i ; ++UpLetter) //second Loop To Ascend Letter printf("%c",FirstChar+UpLetter); for(int DownLetter = i-2 ; DownLetter >= 0 ; --DownLetter) //Thrid Loop To Descend Letter printf("%c",FirstChar+DownLetter); printf("\n"); } return 0; }
第五题
#include<stdio.h> int main(void) { long int FirstNumber; long int LastNumber; printf("PLease Input First Number:"); scanf("%ld",&FirstNumber); printf("Please Input Last NUmber:"); scanf("%ld",&LastNumber); printf("%10s%10s%10s\n","Int","Pow","Cub"); for(long int i = FirstNumber ; i <= LastNumber ; ++i) printf("%10ld%10ld%10ld\n",i,i*i,i*i*i); return 0; }
第六题
#include<stdio.h> #include<string.h> const int Len = 20; int main(void) { char TestWord[Len]; printf("PLease Input Any Word(Max: 20 Letters):"); scanf("%s",TestWord); int Lenght = strlen(TestWord); for(int i = Lenght-1 ; i >= 0 ; --i) printf("%c",TestWord[i]); return 0; }
第七题
#include<stdio.h> #include<math.h> // For abs() int main(void) { double FirstNumber; double SecondNumber; int Switch_1; int Switch_2; printf("Please Input Any Double:"); Switch_1 = scanf("%lf",&FirstNumber); printf("PLease Input Another Double:"); Switch_2 = scanf("%lf",&SecondNumber); while(Switch_1 == 1 && Switch_2 == 1) { printf("%.2f\n",fabs(FirstNumber-SecondNumber) / (FirstNumber * SecondNumber)); printf("Please Input Any Double:"); Switch_1 = scanf("%lf",&FirstNumber); printf("PLease Input Another Double:"); Switch_2 = scanf("%lf",&SecondNumber); } printf("Done\n"); return 0; }
第八题
#include<stdio.h> #include<math.h> // For abs() double pt(double i , double j); int main(void) { double FirstNumber; double SecondNumber; int Switch_1; int Switch_2; printf("Please Input Any Double:"); Switch_1 = scanf("%lf",&FirstNumber); printf("PLease Input Another Double:"); Switch_2 = scanf("%lf",&a 4000 mp;SecondNumber); while(Switch_1 == 1 && Switch_2 == 1) { printf("%.2f\n",pt(FirstNumber,SecondNumber)); printf("Please Input Any Double:"); Switch_1 = scanf("%lf",&FirstNumber); printf("PLease Input Another Double:"); Switch_2 = scanf("%lf",&SecondNumber); } printf("Done\n"); return 0; } double pt(double i , double j) { return fabs(i-j) / (i*j); }
相关文章推荐
- C++ Primer Plus第六版 第六章 编程练习答案
- C++ Primer Plus (第六版)第六章编程练习参考答案
- C Primer Plus(第六版)第六章编程练习答案。
- C ++ Primer Plus 第六版 第六章编程练习答案
- C++ Primer Plus 第五版中文版 第六章 编程练习6
- C++ Primer Plus 课后编程练习——第六章 分支语句和逻辑运算符
- c++ primer plus(第6版)中文版 第六章编程练习答案
- C++ primer plus(sixth edition) 编程练习答案(answers for programing exercises)第六章(chapter 6) 5-9
- C Primer Plus 第六章 编程练习 9-16题
- 《c primer plus》编程练习回顾-第六章
- c++.primer.plus第五版第六章编程练习答案
- C primer plus C 第六章控制语句:循环 编程练习个人练习
- C primer plus(第五版)编程练习第六章
- C++ primer plus编程第六章练习习题代码
- C++ Primer Plus第五版 第六章 编程练习答案
- C.Primer.Plus(第六版)第六章编程练习
- C Primer Plus (第五版) 第六章 编程练习
- C++ Primer Plus 第五版 第六章 编程练习 7
- C++ Primer Plus (第6版)编程练习 代码-----第六章
- C Primer Plus 第六版 第六章 编程练习答案