当前位置:网站首页>"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;
} 边栏推荐
- KS006基于SSM实现学生成绩管理系统
- [rust web rokcet Series 2] connect the database and add, delete, modify and check curd
- matlab 实现语音信号重采样和归一化,并播放比对效果
- Have you stepped on the nine common pits in the e-commerce system?
- Android high frequency network interview topic must know and be able to compare Android development environment
- Cross domain? Homology? Understand what is cross domain at once
- We should make clear the branch prediction
- What are the affordable Bluetooth headsets? Student party parity Bluetooth headset recommendation
- 卷积神经网络(包含代码与相应图解)
- uTools
猜你喜欢

What are the affordable Bluetooth headsets? Student party parity Bluetooth headset recommendation

Develop those things: how to use go singleton mode to ensure the security of high concurrency of streaming media?

Learning notes 25 - multi sensor front fusion technology

Learning note 3 -- Key Technologies of high-precision map (Part 1)

Learning note 24 - multi sensor post fusion technology

学习笔记2--高精度地图定义及价值

Since I understand the idea of dynamic planning, I have opened the door to a new world

PR second training

机器学习基本概念

Learn about servlets
随机推荐
Design and implementation of radio energy transmission system
k线图形态这样记(口诀篇)
6-2漏洞利用-ftp不可避免的问题
Tencent cloud techo youth dream campus trip into Wuhan University
微信小程序中使用tabBar
Six lessons to be learned for the successful implementation of edge coding
[rust web rokcet Series 2] connect the database and add, delete, modify and check curd
人工智能在网络安全中的作用
This is the form of the K-line diagram (pithy formula)
Altium designer measure distance (ctrl+m)
分卷压缩,解压
Unity AssetBundle subcontracting
牛客网——华为题库(51~60)
6-3 vulnerability exploitation SSH environment construction
Based on configured schedule, the given trigger will never fire
Using tabbar in wechat applet
[Floyd] post disaster reconstruction
No converter found for return value of type: class
[Video] visual interpretation of Markov chain principle and Mrs example of R language region conversion | data sharing
浅浅了解Servlet