当前位置:网站首页>"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;
} 边栏推荐
- Brief introduction to the development of mobile network
- This is the form of the K-line diagram (pithy formula)
- Learning note 3 -- Key Technologies of high-precision map (Part 1)
- How can I batch produce the same title for the video?
- Edge computing accelerates live video scenes: clearer, smoother, and more real-time
- 人工智能在网络安全中的作用
- Data visualization in medical and healthcare applications
- 机器学习基本概念
- Feature extraction and detection 16 brisk feature detection and matching
- matlab 使用 audioread 、 sound 读取和播放 wav 文件
猜你喜欢

The smart Park "ZhongGuanCun No.1" subverts your understanding of the park

Six lessons to be learned for the successful implementation of edge coding

KS006基于SSM实现学生成绩管理系统

跨域?同源?一次搞懂什么是跨域

How can I batch produce the same title for the video?

II Basic structure of radio energy transmission system

Another programmer "deleted the library and ran away", deleted the code of the retail platform, and was sentenced to 10 months

Implementation of Weibo system based on SSM

Introduction to ffmpeg Lib

Cross domain? Homology? Understand what is cross domain at once
随机推荐
Ubuntu20.04 PostgreSQL 14 installation configuration record
Matlab uses audiorecorder and recordblocking to record sound, play to play sound, and audiobook to save sound
遊戲思考15:全區全服和分區分服的思考
开发工具创新升级,鲲鹏推进计算产业“竹林”式生长
uTools
Data visualization in medical and healthcare applications
Android: how can golden nine and silver ten squeeze into the first-line big factories from small and medium-sized enterprises? The depth of interview questions in large factories
Three core problems of concurrent programming
Electronic Society C language level 1 32, calculate the power of 2
学习笔记2--高精度地图定义及价值
Memorabilia of domestic database in June 2022
Modeling essays series 124 a simple coding method
Study note 2 -- definition and value of high-precision map
Volume compression, decompression
ECS project deployment
The author is more willing to regard industrial Internet as a concept much richer than consumer Internet
[Obsidian] wechat is sent to Obsidian using remotely save S3 compatibility
MATLAB realizes voice signal resampling and normalization, and plays the comparison effect
卷積神經網絡(包含代碼與相應圖解)
Matlab uses resample to complete resampling