求三角形的周长

给定三角形的边(a,b,c),我们必须求出三角形的周长。

null

周长: 三角形的周长是三角形边长的总和。

Perimeter of a triangle

其中a,b,c是三角形边的长度。 三角形的周长可以简单地用以下公式计算: perimeter = (a + b + c)

例如:

Input : a = 2.0, b = 3.0, c = 5.0
Output : 10.0


Input : a = 5.0, b = 6.0, c = 7.0 
Output : 18.0
推荐:请尝试你的方法 {IDE} 首先,在进入解决方案之前。

C++

// A simple C++ program to find the perimeter
// of triangle
#include <iostream>
using namespace std;
// Function to find perimeter
float findPerimeter( float a, float b, float c)
{
// Formula for finding a perimeter
// of triangle
return (a + b + c);
}
// Driver Code
int main()
{
float a = 2.0, b = 3.0, c = 5.0;
cout << findPerimeter(a, b, c);
return 0;
}
// This code is contributed by Ankita saini


C

// A simple C program to find the perimeter
// of triangle
#include <stdio.h>
// Function to find perimeter
float findPerimeter( float a, float b, float c)
{
// Formula for finding a perimeter of triangle
return (a + b + c);
}
// Driver Code
int main()
{
float a = 2.0, b = 3.0, c = 5.0;
printf ( "%f" , findPerimeter(a, b, c));
return 0;
}


JAVA

// Java program to find perimeter
// of triangle
class Test {
static float findPerimeter( float a, float b, float c)
{
// Formula for Perimeter of triangle
return (a + b + c);
}
// Driver method
public static void main(String[] args)
{
float a = 2.0 , b = 3.0 , c = 5.0 ;
System.out.println(findPerimeter(a, b, c));
}
}


python

# Python Program to find a perimeter
# of triangle
# Function to find perimeter
def findPerimeter(a, b, c):
# Calculate the perimeter
return (a + b + c)
# Driver Code
a = 2.0
b = 3.0
c = 5.0
print (findPerimeter(a, b, c))


C#

// C# program to find perimeter
// of triangle
using System;
class Test {
static float findPerimeter( float a,
float b, float c)
{
// Formula for Perimeter of triangle
return (a + b + c);
}
// Driver method
public static void Main()
{
float a = 2.0f, b = 3.0f, c = 5.0f;
Console.WriteLine(findPerimeter(a, b, c));
}
}
//This code is contributed by vt_m.


PHP

<?php
// A simple PHP program
// to find the perimeter
// of triangle
// Function to find perimeter
function findPerimeter( $a , $b , $c )
{
// Formula for finding a
// perimeter of triangle
return ( $a + $b + $c );
}
// Driver Code
$a = 2.0;
$b = 3.0;
$c = 5.0;
echo findPerimeter( $a , $b , $c );
// This code is contributed by anuj_67.
?>


Javascript

<script>
// JavaScript program to find perimeter
// of triangle
function findPerimeter(a, b, c)
{
// Formula for Perimeter of triangle
return (a + b + c);
}
// Driver Code
let a = 2.0, b = 3.0, c = 5.0;
document.write(findPerimeter(a, b, c));
// This code is contributed by code_hunt
</script>


输出:

10.0

© 版权声明
THE END
喜欢就支持一下吧,技术咨询可以联系QQ407933975
点赞6 分享
CPPKU的头像-yiteyi-C++库
相关推荐
ISRO | ISRO CS 2017 |问题6-yiteyi-C++库
ISRO | ISRO CS 2017 |问题6
ISRO | ISRO CS 2017 |问题6
2年前 373
比特屏蔽和动态编程|集1(计算方法,为每个人分配唯一的上限)-yiteyi-C++库
比特屏蔽和动态编程|集1(计算方法,为每个人分配唯一的上限)
比特屏蔽和动态编程|集1(计算方法,为每个人分配唯一的上限)
2年前 227
SAP位置编码问题-yiteyi-C++库
SAP位置编码问题
SAP位置编码问题
2年前 226
2018年NSIT德里协会黑客团队Geeksforgeks-yiteyi-C++库
2018年NSIT德里协会黑客团队Geeksforgeks
2018年NSIT德里协会黑客团队Geeksforgeks
2年前 219
STD::C++中的NExtx置换和Pype置换-yiteyi-C++库
STD::C++中的NExtx置换和Pype置换
STD::C++中的NExtx置换和Pype置换
2年前 216
抗锯齿线|吴小林算法-yiteyi-C++库
抗锯齿线|吴小林算法
抗锯齿线|吴小林算法
2年前 156