当前位置:网站首页>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;
}
边栏推荐
- Node文件操作
- 看了就会的 Rainbond 入门教程
- BGP experiment
- Swiftui 4.0's new navigation system
- Getting started with scottplot tutorial: getting and displaying values at the mouse
- linux安装mysql
- C# 获取当前路径7种方法
- Langjing Technology (Trax China) "robot +ai" opens the era of Chinese retail meta universe
- 如何让照片中的人物笑起来?HMS Core视频编辑服务一键微笑功能,让人物笑容更自然
- 35道MySQL面试必问题图解,这样也太好理解了吧
猜你喜欢

Another way of understanding the essence of Hamming code
C# 读取ini文件、键值对操作

9、 Uni popup usage popup effect at the bottom of the drop-down box

爆肝整理JVM十大模块知识点总结,不信你还不懂

It's so hot that solar power can't take off? Hello, head

@DS('slave') 多数据源兼容事务问题解决方案
![[Tanabata] Tanabata lonely little frog research edition? The final chapter of Tanabata Festival!](/img/0b/4fc583a3dd4794b0c2b0d64d905be7.png)
[Tanabata] Tanabata lonely little frog research edition? The final chapter of Tanabata Festival!

Forage QR code -- online QR code generator

Minitest -- applet automation testing framework

Digital transformation security issues occur frequently, and Shanshi Netcom helps build a digital government
随机推荐
基础架构之日志管理平台及钉钉&邮件告警通知
聊天室功能的实现
Digital transformation security issues occur frequently, and Shanshi Netcom helps build a digital government
Chi square distribution and gamma function
2022 safety officer-a certificate operation certificate examination question bank simulated examination platform operation
Floating point data type in C language (did you learn to waste it)
使用Weka与Excel进行简单的数据分析
58 sub station Anju, broker marketing management platform login interface encryption reverse
C语言实现简单学生成绩管理系统的方法
C语言中浮点数据类型(你学废了吗)
实时切换 Core Data 的云同步状态
Animation mechanism of swiftui
Afnetworking crash course
(function(global,factory){
Core Data 是如何在 SQLite 中保存数据的
[ecmascript6] other new interface features
分集技术简略
ScottPlot入门教程:获取和显示鼠标处的数值
7月29日 ApacheCon|Apache Pulsar 在 vivo 的探索与实践 即将开播
Several methods of opening URL in swiftui view