当前位置:网站首页>First class exercise
First class exercise
2022-07-28 14:46:00 【Qing Ankang】
Catalog
One 、 Single topic selection
2-1
Overloaded functions are selected based on when calling , The wrong is (D).
A. The parameters of the function
B. Type of parameter
C. Function name
D. Type of function
2-2
The following requirements for defining overloaded functions ,( C) It's wrong. .
A. The number of required parameters is different
B. At least one parameter of different type is required
C. The return value of the function is required to be different
D. The same number of parameters is required , Different parameter types
Two 、 Function questions
6-1 Maximum function overload
fraction 10
author Yang Jun
Company Sichuan Normal University
Write overloaded functions myMax Two integers can be found separately , Three integers , The maximum value of two doubles .
Function interface definition :
Sample referee test procedure :
/* Please fill in the answer here */
int main(){
cout<<myMax(3,4)<<endl;
cout<<myMax(3,4,5)<<endl;
cout<<myMax(4.3,3.4)<<endl;
}
sample input :
nothing
sample output :
Here is the corresponding output . for example :
4
5
4.3
#include<iostream>
using namespace std;
int myMax(int a,int b){
return a>b?a:b;
}
int myMax(int a, int b, int c){
return a>b?(a>c?a:c):(b>c?b:c);
}
double myMax(double a,double b){
return a>b?a:b;
}
3、 ... and 、 Programming questions
7-1 Calculate the area of the triangle
fraction 10
author Zhang Dehui
Company Xi'an University of Posts and Telecommunications
Enter three numbers from the keyboard , Used to represent the length of three sides of a triangle . If you can form a triangle, you will output the area of the triangle , Otherwise output No.
Input format :
Please write the length of the three sides of the triangle here , for example :
3.1 4.2 5.3
Output format :
Please output the area of triangle here , for example :
6.50661
sample input :
3.0 4.0 5.0
sample output :
6
#include <iostream>
#include <cmath>
using namespace std;
int main(){
double a, b, c, p, s;
cin >> a >> b >> c;
if(a+b<=c || a+c<=b || b+c<=a){
cout << "No" << endl;
return 0;
}
p = (a+b+c)/2;
s = sqrt(p*(p-a)*(p-b)*(p-c));
cout << s << endl;
return 0;
}
边栏推荐
- 58 sub station Anju, broker marketing management platform login interface encryption reverse
- MQTT入门级简单介绍与使用
- 用 Table 在 SwiftUI 下创建表格
- Redis-持久化
- Ability to add class @published for custom attribute wrapper types
- 2022年熔化焊接与热切割考题及在线模拟考试
- 2022 safety officer-a certificate operation certificate examination question bank simulated examination platform operation
- How does core data save data in SQLite
- Mobile phone scrolling screenshot software recommendation
- Realization of chat room function
猜你喜欢

Focus on differentiated product design, intelligent technology efficiency improvement and literacy education around new citizen Finance

10、 Timestamp

2022 low voltage electrician examination questions and answers

Various pitfalls encountered in UI development

35道MySQL面试必问题图解,这样也太好理解了吧

HCIP第十二天

使用Weka与Excel进行简单的数据分析

多所“双一流”大学,保研预报名启动!

These three online PS tools should be tried
C # read INI file and key value pair operation
随机推荐
SwiftUI 布局 —— 尺寸( 下 )
Why is it reverse to convert from other formats to BMP
Bulk Rename Utility
Redis-Redis在Jedis中的使用
HCIP第十二天
58子站安居,经纪人营销管理平台登录接口加密逆向
unittest执行runTestCase提示<_io.TextIOWrapper name=‘<stderr>‘ mode=‘w‘ encoding=‘utf-8‘>解决方案
企鹅一面:为什么不建议使用SELECT * ?
Qt中QTableView设置分页显示的三种方法[通俗易懂]
Copy excel row to specified row
[leetcode] 1331. Array sequence number conversion
工厂模式和构造函数模式
Iterator iterator interface
Node文件操作
如何有效进行回顾会议(上)?
These three online PS tools should be tried
卡方分布和伽马函数(Chi-Square Distribution)
Installing MySQL on Linux
&0xffffffff(0x08)
2022 melting welding and thermal cutting examination questions and online simulation examination