当前位置:网站首页>"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;
} 边栏推荐
- 三分钟学会基础k线图知识
- [IVX junior engineer training course 10 papers to get certificates] 03 events and guessing numbers games
- 技术大佬准备就绪,话题C位由你决定
- [IVX junior engineer training course 10 papers to get certificates] 01 learn about IVX and complete the New Year greeting card
- 并发编程的三大核心问题
- Private project practice sharing [Yugong series] February 2022 U3D full stack class 009 unity object creation
- 卷積神經網絡(包含代碼與相應圖解)
- Ks006 student achievement management system based on SSM
- 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
猜你喜欢

【疾病检测】基于BP神经网络实现肺癌检测系统含GUI界面

matlab 使用 audiorecorder、recordblocking录制声音,play 播放声音,audiowrite 保存声音

Edge computing accelerates live video scenes: clearer, smoother, and more real-time
![[Obsidian] wechat is sent to Obsidian using remotely save S3 compatibility](/img/8b/e51867cfe9d200ac385e1d1f01e4b3.jpg)
[Obsidian] wechat is sent to Obsidian using remotely save S3 compatibility

Pyldavis installation and use | attributeerror: module 'pyldavis' has no attribute' gensim '| visual results are exported as separate web pages
![[IVX junior engineer training course 10 papers to get certificates] 03 events and guessing numbers games](/img/69/44219af52baef20cedec3870147589.jpg)
[IVX junior engineer training course 10 papers to get certificates] 03 events and guessing numbers games

Number of palindromes in C language (leetcode)

6-3 vulnerability exploitation SSH environment construction

Cross domain? Homology? Understand what is cross domain at once

如何远程、在线调试app?
随机推荐
微信小程序中使用tabBar
SAP ui5 beginner tutorial 20 - explanation of expression binding usage of SAP ui5
Finally got byte offer, 25-year-old inexperienced experience in software testing, to share with you
Error creating bean with name ‘stringRedisTemplate‘ defined in class path re
技术大佬准备就绪,话题C位由你决定
Android high frequency network interview topic must know and be able to compare Android development environment
Learning note 3 -- Key Technologies of high-precision map (Part 1)
Volume compression, decompression
[rust web rokcet Series 2] connect the database and add, delete, modify and check curd
What are the skills of spot gold analysis?
Feature extraction and detection 16 brisk feature detection and matching
Develop those things: how to use go singleton mode to ensure the security of high concurrency of streaming media?
Single chip microcomputer -- hlk-w801 transplant NES simulator (III)
Failed to transform file 'xxx' to match attributes
Matlab uses audioread and sound to read and play WAV files
Laravel artisan common commands
游戏思考15:全区全服和分区分服的思考
开发那些事儿:如何利用Go单例模式保障流媒体高并发的安全性?
Introduction to ffmpeg Lib
Altium designer measure distance (ctrl+m)