Dado un número entero a que es el lado de un cuadrado, la tarea es encontrar el Triángulo de Reuleaux más grande que se puede inscribir en él.
Ejemplos:
Entrada: a = 6
Salida: 25.3717Entrada: a = 8
Salida: 45.1053
Enfoque : Sabemos que el Área del Triángulo de Reuleaux es 0.70477 * b 2 donde b es la distancia entre las líneas paralelas que sostienen el Triángulo de Reuleaux.
De la figura, está claro que la distancia entre líneas paralelas que sostienen el Triángulo de Reuleaux = Lado del cuadrado, es decir , a
Por lo tanto, Área del Triángulo de Reuleaux, A = 0.70477 * a 2
A continuación se muestra la implementación del enfoque anterior:
C++
// C++ Program to find the area // of the biggest Reuleaux triangle // that can be inscribed within a square #include <bits/stdc++.h> using namespace std; // Function to find the Area // of the Reuleaux triangle float ReuleauxArea(float a) { // Side cannot be negative if (a < 0) return -1; // Area of the Reuleaux triangle float A = 0.70477 * pow(a, 2); return A; } // Driver code int main() { float a = 6; cout << ReuleauxArea(a) << endl; return 0; }
Java
// Java Program to find the area // of the biggest Reuleaux triangle // that can be inscribed within a square import java.lang.Math; class cfg { // Function to find the Area // of the Reuleaux triangle static double ReuleauxArea(double a) { // Side cannot be negative if (a < 0) return -1; // Area of the Reuleaux triangle double A = 0.70477 * Math.pow(a, 2); return A; } // Driver code public static void main(String[] args) { double a= 6; System.out.println(ReuleauxArea(a) ); } }//This code is contributed by Mukul Singh.
Python3
# Python3 Program to find the area # of the biggest Reuleaux triangle # that can be inscribed within a square # Function to find the Area # of the Reuleaux triangle def ReuleauxArea(a) : # Side cannot be negative if (a < 0) : return -1 # Area of the Reuleaux triangle A = 0.70477 * pow(a, 2); return A # Driver code if __name__ == "__main__" : a = 6 print(ReuleauxArea(a)) # This code is contributed by Ryuga
C#
// C# program to find area of the //biggest Reuleaux triangle that can be inscribed //within a square using System; class GFG { // Function to find the area // of the reuleaux triangle static double reuleauxArea(double a) { //Side cannot be negative if (a<0) return -1; // Area of the reauleaux triangle double A=0.70477*Math.Pow(a,2); return A; } // Driver code static public void Main() { double a= 6; Console.WriteLine(reuleauxArea( a)); } } //This code is contributed by Mohit kumar 29
PHP
<?php // PHP Program to find the area of the // biggest Reuleaux triangle that can // be inscribed within a square // Function to find the Area // of the Reuleaux triangle function ReuleauxArea($a) { // Side cannot be negative if ($a < 0) return -1; // Area of the Reuleaux triangle $A = 0.70477 * pow($a, 2); return $A; } // Driver code $a = 6; echo ReuleauxArea($a) . "\n"; // This code is contributed by ita_c ?>
Javascript
<script> // javascript Program to find the area // of the biggest Reuleaux triangle // that can be inscribed within a square // Function to find the Area // of the Reuleaux triangle function ReuleauxArea(a) { // Side cannot be negative if (a < 0) return -1; // Area of the Reuleaux triangle var A = 0.70477 * Math.pow(a, 2); return A; } // Driver code var a= 6; document.write(ReuleauxArea(a) ); // This code is contributed by Princi Singh </script>
25.3717
Complejidad de tiempo: O(1)
Espacio Auxiliar: O(1)
Publicación traducida automáticamente
Artículo escrito por IshwarGupta y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA