CPP2022-10-函数01(上)

简介: CPP2022-10-函数01

 

1. double dist( double x1, double y1, double x2, double y2 )
2. {
3. return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
4. }

1. int sign( int x )
2. {
3. if(x>0)
4.     {
5. return 1;
6.     }
7. else if(x==0)
8.     {
9. return 0;
10.     }
11. else
12.     {
13. return -1;
14.     }
15. }

1. double fact( int n )
2. {
3. if(n==1)
4.     {
5. return 1;
6.     }
7. else
8.     {
9. return n*fact(n-1);
10.     }
11. }

1. int IsSquare( int n )
2. {
3. if((long long int)sqrt(n)*(long long int)sqrt(n)==n)
4.     {
5. return 1;
6.     }
7. return 0;
8. }

 

相关文章
|
2月前
|
C++
如何在C++中实现cpp文件中引用另外一个cpp文件
如何在C++中实现cpp文件中引用另外一个cpp文件
139 0
|
2月前
|
存储 openCL 异构计算
解决 ChatGLM.CPP+clBlast 编译错误(也适用于SD.CPP)
解决 ChatGLM.CPP+clBlast 编译错误(也适用于SD.CPP)
65 0
|
12月前
|
机器学习/深度学习 人工智能 网络协议
CPP2022-23-函数进阶-函数指针
CPP2022-23-函数进阶-函数指针
210 0
|
12月前
CPP2022-10-函数01(下)
CPP2022-10-函数01(下)
33 0
|
12月前
CPP2022-11-数组01(上)
CPP2022-11-数组01
128 0
|
12月前
CPP2022-03
CPP2022-03
34 0
|
12月前
|
人工智能
CPP2022-11-数组01(下)
CPP2022-11-数组01(下)
208 0
|
并行计算 异构计算
错误:customWinogradConvActLayer.cpp
错误:customWinogradConvActLayer.cpp
68 0
Ogrekit共享库main.cpp源码
Ogrekit共享库main.cpp源码
58 0