当前位置:网站首页>"C language programming", 4th Edition, edited by he Qinming and Yan Hui, after class exercise answers Chapter 3 branch structure Exercise 3
"C language programming", 4th Edition, edited by he Qinming and Yan Hui, after class exercise answers Chapter 3 branch structure Exercise 3
2022-07-02 01:43:00 【Bathe in the four seasons】
exercises 3 P064~067
One 、 choice question
1~5 CBADD 6~8 CAB
Two 、 Completion
1、32 585858
2、(x>10&&x<100)||x<0
3、x%2==0 first==1 first=0 printf("%d",x) ( The answer is tentative )
4、onetwo
5、max=a max=c b>c max=c
3、 ... and 、 Programming problem
exercises 1~5
#include<stdio.h>
#include<math.h>
int main(void)
{
int a,b,c,max;// exercises 3.1
printf("Enter a,b,c:");
scanf("%d%d%d",&a,&b,&c);
max=a;
if(b>c){
if(b>max) {
max=b;
if(a>c) printf(" From small to large :%d,%d,%d\n",c,a,b);
else printf(" From small to large :%d,%d,%d\n",a,c,b);
}
else{if(b>c) printf(" From small to large :%d,%d,%d\n",c,b,a);
else printf(" From small to large :%d,%d,%d\n",b,c,a);}}
else{
if(c>max){
max=c;
if(a>b) printf(" From small to large :%d,%d,%d\n",b,a,c);
else printf(" From small to large :%d,%d,%d\n",a,b,c);
}}
printf("\n");
/* Highway speeding penalty ( exercises 3.2)*/
double n=120,x;
printf("Enter x( Is the actual speed of the vehicle ):");
scanf("%lf",&x);
if(x>=n*1.1&&x<n*1.5)
printf(" You have exceeded the speed limit 10%, Penalty 200 element \n");
else if(x>=n*1.5) printf(" You have exceeded the speed limit 50%, The driver's license has been revoked \n");
else ;
printf("\n");
/* Taxi pricing ( exercises 3.3)*/{
double x,m,y;
printf(" Enter the mileage x(x>0), Temporary parking time m:");
scanf("%lf%lf",&x,&m);
if(x<=3)
y=10+(m/5.0)*2;
else if(3<x<=13) y=10+(x-3)*2+(m/5.0)*2;
else y=10+10*2+(x-13)*3+m/5*2;// Input here 14 deserved 33, But the result is 32, It should be the computer .
printf(" The fare payable by passengers is :%.lf\n",y);}
printf("\n");
/* Count the student's scores ( exercises 3.4)*/{
int score,n,i,A=0,B=0,C=0,D=0,E=0;
printf("Enter n:");
scanf("%d",&n);
printf(" Input % individual score(1~100):",n);
for(i=1;i<=n;i++)
{
scanf("%d",&score);
printf(" Enter the percentile score %d The corresponding five point score is :",score);
if(score>=90){
putchar('A');putchar('\n');A++;}
else if(80<=score){
putchar('B');putchar('\n');B++;}
else if(70<=score){
putchar('C');putchar('\n');C++;}
else if(60<=score){
putchar('D');putchar('\n');D++;}
else { putchar('E');putchar('\n');E++;}
}
printf(" Grade proportion :A=%d,B=%d,C=%d,D=%d,E=%d\n",A,B,C,D,E);}
printf("\n");
/* Triangle judgment ( exercises 3.5)*/{
double x1,y1,x2,y2,x3,y3,S,C,area,a,b,c;
printf(" Enter the coordinates of the three points (x1,y1),(x2,y2),(x3,y3):");
scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
a=sqrt(pow(x2-x1,2)+pow(y2-y1,2));
b=sqrt(pow(x3-x2,2)+pow(y3-y2,2));
c=sqrt(pow(x1-x3,2)+pow(y1-y3,2));
if((a+b>c)&&(a+c>b)&&(b+c>a)&&(a-b<c)&&(a-c<b)&&(b-c<a))
{
C=a+b+c;
S=(a+b+c)/2.0;
area=sqrt(S*(S-a)*(S-b)*(S-c));
printf(" The circumference of this triangle is %.2lf, Area is %.2lf",C,area);
}
else printf("Impossible");}
return 0;
}
边栏推荐
- 迁移云计算工作负载的四个基本策略
- 学习笔记3--高精度地图关键技术(上)
- Brief introduction to the development of mobile network
- Look at the industrial Internet from a new perspective and seek the correct ways and methods of industrial Internet
- Android: the kotlin language uses grendao3, a cross platform app development framework
- 电子协会 C语言 1级 33 、奇偶数判断
- Data visualization in medical and healthcare applications
- Electronic Society C language level 1 32, calculate the power of 2
- Convolutional neural network (including code and corresponding diagram)
- 电子协会 C语言 1级 32、计算2的幂
猜你喜欢
遷移雲計算工作負載的四個基本策略
Unity AssetBundle subcontracting
游戏思考15:全区全服和分区分服的思考
How can I batch produce the same title for the video?
Self drawing of menu items and CListBox items
Volume compression, decompression
[IVX junior engineer training course 10 papers to get certificates] 09 chat room production
[IVX junior engineer training course 10 papers] 06 database and services
成功实现边缘编码需要了解的六大经验教训
微信小程序中使用tabBar
随机推荐
There are spaces in the for loop variable in the shell -- IFS variable
城市选择器组件实现原理
Unity AssetBundle subcontracting
How can I batch produce the same title for the video?
matlab 使用 audioread 、 sound 读取和播放 wav 文件
Basic concepts of machine learning
Another programmer "deleted the library and ran away", deleted the code of the retail platform, and was sentenced to 10 months
Learn C language from scratch day 025 (maze)
Memorabilia of domestic database in June 2022
如何用一款产品推动「品牌的惊险一跃」?
PR second training
Android: the kotlin language uses grendao3, a cross platform app development framework
LeetCode、3无重复最长子序列
Brief description of grafana of # yyds dry goods inventory # Prometheus
Matlab uses resample to complete resampling
学习笔记2--高精度地图定义及价值
[disease detection] realize lung cancer detection system based on BP neural network, including GUI interface
基于SSM实现微博系统
Based on configured schedule, the given trigger will never fire
Finally got byte offer, 25-year-old inexperienced experience in software testing, to share with you