本文概述
- C ++
- Java
- Python3
- C#
- 的PHP
- C ++
- Python3
- Java
- C#
- 的PHP
正方形的周长:
文章图片
正方形的周长由以下公式给出:
C = 4 * awhere a is the side length.
例子 :
input: 4output: 16input: 3output: 12
C ++
//CPP program to find
//Circumference of a square
#include <
bits/stdc++.h>
using namespace std;
int Circumference( int a)
{
return 4 * a;
}//Driver Code
int main()
{
int a = 5;
cout <
<
"Circumference of"
<
<
" a square is "
<
<
Circumference(a);
return 0;
}//This code is contributed
//by mohitw16
Java
//Java program to find
//Circumference of a squareimport java.io.*;
class GFG
{
int Circumference( int a)
{
return 4 * a;
}//Driver code
public static void main(String args[])
{
GFG obj = new GFG();
int a = 5 ;
System.out.println( "Circumference of " +
"a square is " +
obj.Circumference(a));
}
}//This code is contributed
//by Anshika Goyal.
Python3
# Python3 Program to find
# Circumference of a squaredef Circumference(a):
return ( 4 * a)# Driver code
a = 5
c = Circumference(a)
print ( "Circumference of a " +
"square is % d" % (c))
C#
//C# program to find Circumference
//of a square
using System;
class GFG
{static int Circumference( int a)
{
return 4 * a;
}//Driver Code
public static void Main()
{
int a = 5;
Console.WriteLine( "Circumference" +
" of a square is " +
Circumference(a));
}
}//This code is contributed by vt_m.
的PHP
<
?php
//PHP program to find
//Circumference of a squarefunction Circumference( $a )
{
return 4 * $a ;
}//Driver Code
$a = 5;
echo "Circumference of a " .
"square is " , Circumference( $a );
//This code is contributed by ajit
?>
输出:
Circumference Of a square is 20
矩形的周长:
文章图片
矩形的周长由以下公式给出:
C = 2 * (l + W)where l is the length and W is the width.
例子 :
input: 2 4output: 12input: 4 6output: 20
C ++
//C++ Program to find
//Circumference of a rectangle
#include <
iostream>
using namespace std;
int Circumference( int l, int w)
{
return (2 * (l + w));
}//Driver code
int main()
{
int l = 8, w = 4;
int c = Circumference(l, w);
cout <
<
"Circumference of a"
<
<
" rectangle is "
<
<
c <
<
endl;
return 0;
}//This code is contributed by vt_m.
Python3
# Python Program to find
# Circumference of a rectangledef Circumference(l, w):
return ( 2 * (l + w))# Driver code
l = 8
w = 4
c = Circumference(l, w)
print ( "Circumference of a" +
" rectangle is % d" % (c))
Java
//java Program to find
//Circumference of a rectangle
import java.io.*;
class GFG
{static int Circumference( int l, int w)
{
return ( 2 * (l + w));
}//Driver code
static public void main(String[] args)
{
int l = 8 , w = 4 ;
int c = Circumference(l, w);
System.out.println( "Circumference of " +
"a rectangle is " + c);
}
}//This code is contributed by vt_m.
C#
//C# Program to find
//circumference of a rectangle
using System;
class GFG
{static int Circumference( int l, int w)
{
return (2 * (l + w));
}//Driver code
static public void Main()
{
int l = 8, w = 4;
int c = Circumference(l, w);
Console.WriteLine( "Circumference of " +
"a rectangle is " + c);
}
}//This code is contributed by vt_m.
的PHP
<
?php
//Php Program to find
//Circumference of a rectanglefunction Circumference( $l , $w )
{
return (2 * ( $l + $w ));
}//Driver code
$l = 8;
$w = 4;
$c = Circumference( $l , $w );
echo "Circumference of a " .
"rectangle is " , $c , "\n" ;
//This code is contributed by aj_36.
?>
【查找正方形和矩形的周长/周长的程序】输出:
Circumference of a rectangle is 24
推荐阅读
- 使用Python程序爬取网页并获得最常用的单词
- Python如何实现图像强度转换操作()
- Python程序使用OpenCV提取帧|视频操作
- 查找奇数次出现的数字的Python程序
- 最大和连续子数组的Python程序
- 数学建模|【建模算法】基于模拟退火算法求解TSP问题(Python实现)
- 数学建模|【建模算法】Python调用scikit-opt工具箱中的模拟退火算法求解TSP问题
- 算法|冲刺秋招!最全面的机器学习知识复习及巩固攻略
- Python|模拟退火算法解决TSP(python实现 110+行代码)【gif生成】