área de un triangulo
lic double areaTriangle(double a, double b, double c)
{
return (a * b * Math.Sqrt(Math.Pow(c, 2) - Math.Pow(a, 2) - Math.Pow(b, 2))) / 2;
}
public double areaSquare(double a)
{
return a * a;
}
public double area
Generate code just by typing a text description. AI will create the code for you. Test it now
Generate
More than just a code generator. A tool that helps you with a wide range of tasks. All in one place.
Function from Description
Text Description to SQL Command
Translate Languages
Generate HTML from Description
Code to Explanation
Fix invalid Code
Get Test for Code
Class from Description
Regex from Description
Regex to Explanation
Git Command from Description
Linux Command
Function from Docstring
Add typing to code
Get Language from Code
Time complexity
CSS from Description
Meta Tags from Description
Generated by the communtiy
lic double areaTriangle(double a, double b, double c)
{
return (a * b * Math.Sqrt(Math.Pow(c, 2) - Math.Pow(a, 2) - Math.Pow(b, 2))) / 2;
}
public double areaSquare(double a)
{
return a * a;
}
public double area
def get_police_users(department):
import ldap
import re
from openpyxl import Workbook
from openpyxl import load_workbook
wb = Workbook()
ws = wb.active
# connect to active directory
conn = ldap.initialize('ldap://ldap.yourdomain.com')
# search for users in department in active directory
results = conn.search_s('dc=yourdomain,dc=com', ldap.SCOPE_SUBTREE, "department=" + department, ['cn'])
# create spreadsheet and add users in department to it
ws.append(["Users"])
for result in results:
ws.append([re.findall('(?<=cn=).*', result[1]['cn'][0].decode('utf-8'))[0]])
wb.save("output.xlsx")
# open spreadsheet and sort by last name
wb = load
#include <stdio.h>
int main(int argc, char const *argv[])
{
int n;
scanf("%d", &n);
int numbers[n];
for (int i = 0; i < n; i++)
{
int number;
scanf("%d", &number);
numbers[i] = number;
}
int sumOfEvens = 0;
int sumOfOdds = 0;
for (int i = 0; i < n; i++)
{
int number = numbers[i];
if (number % 2 == 0)
{
sumOfEvens += number;
}
else
{
sumOfOdds += number;
}
}
printf("%d\n", sumOfEvens);
if (sumOfOdds == 0)
{
printf("No hay números impares");
}
else
{
printf("%.2
#include <iostream>
using namespace std;
int main() {
int n = 0;
float costo = 0;
cout << "Ingrese la cantidad de pelotas que desea comprar: \n";
cin >> n;
if (n <= 10){
costo = n * 7.00;
cout << "El valor total a pagar es: " << costo << " dolares" << endl;
}
else{
costo = n * 6.50;
cout << "El valor total a pagar es: " << costo << " dolares" << endl;
}
return 0;
}
# -*- coding: utf-8 -*-
# Copyright (c) 2019, DigiThinkIT and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
class ProductDetector(Document):
pass
import os
def speak(text):
os.system(f'powershell.exe -Command "Add-Type -AssemblyName System.speech; (New-Object System.Speech.Synthesis.SpeechSynthesizer).Speak(\'{text}\');"')
speak('Test')
Script
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout
})
readline.question(`dime cuantas filas quieres`, (rows) => {
readline.question(`dime cuantas columnas quieres`, (columns) => {
console.log(`Vamos a crear una matriz de ${rows} filas y ${columns} columnas`)
let matrix = createMatrix(rows, columns)
printMatrix(matrix)
let minInfo = getMin(matrix)
console.log(`El minimo es: ${minInfo.value} y está en las posiciones (${minInfo.i}, ${minInfo.j})`)
let maxInfo = getMax(matrix)
console.log(`El maximo es: ${maxInfo.value} y está en las posiciones (${maxInfo.i}, ${maxInfo.j})`)
readline.close()
var name = "Mauricio"
var age = 30
var isDeveloper = true
var birthDate = new Date(1990, 7, 17)
var list = [name, age, isDeveloper, birthDate]
console.log(list)
import os
def speak(text):
os.system(f'powershell.exe -Command "Add-Type -AssemblyName System.speech; (New-Object System.Speech.Synthesis.SpeechSynthesizer).Speak(\'{text}\');"')
speak('Test')
b <- c(1,1,1,1,1,1,1,0,0,0,0,0,0,0)
while (mean(b) > 0.40) {
b[sample(which(b==1), 1)] <- 0
}
int main(){
int i;
for(i=8;i<=500;i+=8){
printf("\n%d",i);
}
return 0;
}
fun hola(name: String) {
println("Hola $name")
}
hola("Miguel")
while (i <= 100) {
j = 2;
while (j <= (int) Math.sqrt(i)) {
if (i % j == 0) break;
// else
j++;
}
if (j > (int) Math.sqrt(i)) {
// i is prime
if (Math.sqrt(i) % 1 == 0) {
// i is square
System.out.println(i);
}
}
i++;
}
def file_to_dict(file_name):
file_dict = {}
# open the file
with open(file_name) as f:
# loop through each line in the file
for line in f:
# remove new line character
key = line.rstrip()
# get the number of files in the directory
file_dict[key] = len(os.listdir(key))
return file_dict
def file_to_sorted_list(file_name):
file_dict = file_to_dict(file_name)
# return a list of directory name and number of files
return sorted(file_dict.items(), key=lambda kv: kv[1])
# test
for dir_name, number_of_files in file_to_sorted_list('directorios.txt'):
print(f'{dir_name} has {number_of_files} files')
private void extract_Click(object sender, EventArgs e)
{
string input = data.Text;
string[] parts = input.Split(',');
foreach (string part in parts)
{
listBox1.Items.Add(part);
}
}
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
plt.axes(projection=ccrs.PlateCarree())
plt.contourf(lon, lat, temp_data[0, :, :], 60, transform = ccrs.PlateCarree())
plt.colorbar(orientation='horizontal', shrink = 0.8)
plt.show()
int main() {
string nombre;
cout << "Escribe tu nombre: ";
cin >> nombre;
cout << "Hola " << nombre << "!!" << endl;
return 0;
}
A = {1,2,3,4,5}
B = {4,5,6,7,8}
A | B
//in MainTransactionForm.Xaml.cs
public partial class MainTransactionForm : Form
{
public MainTransactionForm()
{
InitializeComponent();
}
private void withdrawButton_Click(object sender, EventArgs e)
{
LoginForm loginForm = new LoginForm();
loginForm.WithdrawChecking();
}
}
//in LoginForm.Xaml.cs
class LoginForm
{
public void WithdrawChecking()
{
if(true)
{
MessageBox.Show("withdraw checking");
}
}
}
ALCULADORA DE PENTAGONO CON UN LADO
import math
def area(lado):
area = lado * lado * math.sqrt(25 + 10 * math.sqrt(5)) / 4
return area
area(2)
for (int i = 0; i < n / 2; i++) {
for (int j = i; j < n - i - 1; j++) {
int tmp = mat[i][j];
mat[i][j] = mat[j][n - i - 1];
mat[j][n - i - 1] = mat[n - i - 1][n - j - 1];
mat[n - i - 1][n - j - 1] = mat[n - j - 1][i];
mat[n - j - 1][i] = tmp;
}
}
int main(){
int i;
for(i=8;i<=500;i+=8){
printf("\n%d",i);
}
return 0;
}
void registrarCamion(int camion, int chofer)
{
if(camionesAgregados>=10)
return;
if(chofer>=10||chofer<0)
return;
if(choferes[chofer]==-1)
return;
if(camiones[camion]!=-1)
return;
camiones[camion]=chofer;
camionesAgregados++;
}
#include<iostream>
#include<string>
using namespace std;
int main(){
int n;
cout<<"enter number: ";
cin>>n;
string str = to_string(n);
cout<<str<<endl;
cout<<"sum is: ";
int sum = 0;
for(int i = 0; i < str.length(); i += 2){
string s;
s += str[i];
s += str[i+1];
sum += stoi(s);
}
cout<<sum<<endl;
}
def download_file(url):
# download url
# return file_path
return file_path
vehiculos = []
def grabar(tipo, patente, marca, precio, multa_monto, multa_fecha, reg_fecha, dueño):
vehiculos.append([tipo, patente, marca, precio, multa_monto, multa_fecha, reg_fecha, dueño])
def buscar(patente):
for vehiculo in vehiculos:
if vehiculo[1] == patente:
print(vehiculo)
return True
return False
def even(x):
if x == 1 or x == 0:
return False
else:
return even(x - 2)
even(3)
DELIMITER //
CREATE PROCEDURE ListProducts()
BEGIN
SELECT * FROM Products
INNER JOIN Categories
ON
Products.categoryID = Categories.categoryID
INNER JOIN Suppliers
ON
Products.supplierID = Suppliers.supplierID
END //
DELIMITER ;
# -*- coding: utf-8 -*-
# Copyright (c) 2019, DigiThinkIT and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
class ProductDetector(Document):
pass
def factorial(n):
total = 1
for i in range(1, n + 1):
total *= i
return total
factorial(5)
def print_message(message):
print(message)
def main():
print_message("Hello, world!")
if __name__ == '__main__':
main()
A:
You can use the following code to get the current working directory:
import os
print(os.getcwd())
A:
You can use os.path.
a = input("a:")
b = input("b:")
if a > b:
print(a)
else:
print(b)
<a href="mailto:+79186788247">+79186788247</a>
import spacy
import sys
import pickle
nlp = spacy.load('en_core_web_sm', disable=['parser', 'tagger'])
def extract_experience(text):
doc = nlp(text)
X = pd.DataFrame([[ent.text, ent.start_char, ent.end_char, ent.label_] for ent in doc.ents],
columns = ["text", "start", "end", "label"])
X_test = X[X["label"] == "ORG"].copy()
X_test["tokens"] = X_test["text"].apply(lambda x: [token.text for token in x.split()])
with open(f"model.pkl", 'rb') as f:
model = pickle.load(f)
y_pred = model.predict(X_test["tokens"])
return list(zip(X_test["text"], y_pred))
def factorial(n):
total = 1
for i in range(1, n + 1):
total *= i
return total
factorial(5)
<table>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
</table>
a = input("a:")
b = input("b:")
if a > b:
print(a)
else:
print(b)
<table>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
</table>
def sum_of_integers(n):
sumatoria = 0
for i in range(1, 101):
if i % n == 0:
sumatoria += i
return sumatoria
sum_of_integers(3)
nclude <iostream>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <iterator>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <sstream>
#include <complex>
#include <limits>
#include <cctype
import os
def speak(text):
os.system(f'powershell.exe -Command "Add-Type -AssemblyName System.speech; (New-Object System.Speech.Synthesis.SpeechSynthesizer).Speak(\'{text}\');"')
speak('Test')
#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
int main()
{
float producto[3][4][12],promedio[4][12];
int i,j,k;
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
{
for(k=0;k<12;k++)
{
printf("Ingrese venta del producto %d, mes %d, año %d\n",i+1,j+1,k+1);
scanf("%f",&producto[i][j][k]);
}
}
}
for(j=0;j<4;j++)
{
for(k=0;k<12;k++)
{
promedio[j][k]=0;
for(i=0;i<3;i++)
{
promedio[j][k
#include <stdio.h>
#include <pthread.h>
void *thread_func(void *arg) {
printf("New thread created\n");
return NULL;
}
int main() {
pthread_t tid;
pthread_create(&tid, NULL, thread_func, NULL);
pthread_join(tid, NULL);
return 0;
}
function palindrome_check($string){
if (strrev($string) == $string){
echo "The string is a palindrome";
} else {
echo "The string isn't a palindrome";
}
}
palindrome_check("madam");
void histgram2(int a[], int n, int h[], int m) {
int i, j, k;
i = 0;
j = 0;
k = 0;
while (i < n) {
if (m * k <= a[i] && a[i] < m * (k + 1)) {
h[k]++;
} else {
k++;
h[k]++;
}
i++;
}
}
float volumenEsfera(float radio){
float volumen;
volumen = 4 * M_PI * pow(radio,3) / 3;
return volumen;
}
public class Ejercicio02 {
public static void main(String[] args) {
int[] numeros = new int[20];
int suma = 0;
int media;
System.out.println("Array original:");
for (int i = 0; i < 20; i++) {
numeros[i] = (int)(Math.random() * 401);
System.out.print(numeros[i] + " ");
suma += numeros[i];
}
System.out.println("\n\nArray modificado:");
media = suma / 20;
for (int i = 0; i < 20; i++) {
if (numeros[i] < media) {
numeros[i] = numeros[i] * -1;
}
System.out.print(numeros[i] + " ");
}
}
}
b <- c(1,1,1,1,1,1,1,0,0,0,0,0,0,0)
while (mean(b) > 0.40) {
b[sample(which(b==1), 1)] <- 0
}
The regex matches the first bracket, then any character, then any number of characters, then a comma.
import mysql.connector
conecction = mysql.connector.connect(host = '192.168.0.20', user = 'root', password = 'admin', database = 'FeedLot')
cursor = conecction.cursor()
def menu():
print("***************************************")
print("* 1. Archivo: *")
print("* 2. Reporte: *")
print("* 3. Consulta: *")
print("* 4. Salir: *")
print("***************************************")
def submenu():
print("***************************************")
print("* 1. Reporte semanal: *")
print("* 2. Reporte mensual: *")
print("* 3. Reporte anual: *")
print("* 4. Salir: *")
print("***************************************")
def crearReporte():
print("***************************************")
print("* 1. Reporte semanal: *")
print("
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
plt.axes(projection=ccrs.PlateCarree())
plt.contourf(lon, lat, temp_data[0, :, :], 60, transform = ccrs.PlateCarree())
plt.colorbar(orientation='horizontal', shrink = 0.8)
plt.show()
def drawArrow(turtle, size):
for i in range(0, 4):
turtle.forward(size)
turtle.right(90)
drawArrow(turtle, 100)
unction of the human body is to maintain homeostasis. The body is constantly adapting to the environment and to the internal environment. The body is constantly adapting to the environment and to the internal environment. The body is constantly adapting to the environment and to the internal environment. The body is constantly
Script
function add(a, b) {
return a + b;
}
UPDATE Projects SET name = TRIM(name);
function hablarEspañol(persona) {
if (persona === "español" || persona === "colombiano") {
console.log("¡Hola!");
} else {
console.log("¡Hablas inglés!");
}
}
def invoice(name, amount, **kwargs):
print(f"Name={name} Amount={amount}")
for k,v in kwargs.items():
print(f"{k} : {v}")
invoice("Paula", 100, tax=0.16, tip=1.2)
fn swap(left: &mut usize, right: &mut usize) {
let temp = *left;
*left = *right;
*right = temp;
}
fn main() {
let mut left = 1;
let mut right = 2;
swap(&mut left, &mut right);
println!("left: {}, right: {}", left, right);
}
Aquí te muestro un ejemplo de cómo crear un cronómetro con HTML, CSS y JavaScript:
**HTML**
```html
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cronómetro</title>
<link rel="stylesheet" href="estilos.css">
</head>
<body>
<div class="cronometro">
<h1 id="tiempo">00:00:00</h1>
<button id="start">Iniciar</button>
<button id="stop">Detener</button>
<button id="reset">Resetear</button>
</div>
<script src="script.js"></script>
</body>
</html>
```
**CSS (en el archivo estilos.css)**
```css
.cronometro {
width: 300px;
margin: 50px auto;
text-align: center;
}
#tiempo {
font-size: 48px;
font-weight: bold;
margin-bottom: 20px;
}
```
**JavaScript (en el archivo script.js)**
```javascript
let tiempo = 0;
let intervalo;
document.getElementById('start').addEventListener('click', () => {
intervalo = setInterval(() => {
tiempo++;
let horas = Math.floor(tiempo / 3600);
let minutos = Math.floor((tiempo % 3600) / 60);
let segundos = tiempo % 60;
document.getElementById('tiempo').innerHTML = `${horas.toString().padStart(2, '0')}:${minutos.toString().padStart(2, '0')}:${segundos.toString().padStart(2, '0')}`;
}, 1000);
});
document.getElementById('stop').addEventListener('click', () => {
clearInterval(intervalo);
});
document.getElementById('reset').addEventListener('click', () => {
clearInterval(intervalo);
tiempo = 0;
document.getElementById('tiempo').innerHTML = '00:00:00';
});
```
En este ejemplo, creamos un cronómetro que cuenta desde 0 y muestra el tiempo en formato HH:MM:SS. Los botones "Iniciar", "Detener" y "Resetear" permiten controlar el cronómetro.
* El botón "Iniciar" inicia el cronómetro y comienza a contar el tiempo.
* El botón "Detener" detiene el cronómetro y para la cuenta regresiva.
* El botón "Resetear" reinicia el cronómetro y establece el tiempo en 0.
Espero que esto te ayude. ¡Si tienes alguna pregunta o necesitas más ayuda, no dudes en preguntar!
A = {1,2,3,4,5}
B = {4,5,6,7,8}
A | B
public class Pila{
int [] pila = new int[10];
int cima = -1;
public void push(int x){
cima++;
pila[cima] = x;
}
public void pop(){
cima--;
}
public boolean empty(){
return cima == -1;
}
public int size(){
return cima+1;
}
public int top(){
return pila[cima];
}
public void ordena(){
for( int i=0; i<pila.length; i++){
for( int j=i+1; j<pila.length; j++){
if(pila[j] < pila[i]){
int t = pila[i];
pila[i] = pila[j];
pila[j] = t;
}
}
}
}
public void imp
Aquí te presento un programa en C++ que calcula el área de un rombo a partir de la longitud de sus diagonales.
```cpp
#include <iostream>
#include <cmath>
// Función para calcular el área de un rombo
double calcularAreaRombo(double diagonalMayor, double diagonalMenor) {
// Verificar si las diagonales son iguales (rombo equilátero)
if (diagonalMayor == diagonalMenor) {
// En este caso, el área es la mitad del producto de las diagonales
return (diagonalMayor * diagonalMenor) / 2;
} else {
// En este caso, el área es la mitad del producto de las diagonales
return (diagonalMayor * diagonalMenor) / 2;
}
}
int main() {
double diagonalMayor, diagonalMenor;
// Pedir la longitud de la diagonal mayor
std::cout << "Ingrese la longitud de la diagonal mayor: ";
std::cin >> diagonalMayor;
// Pedir la longitud de la diagonal menor
std::cout << "Ingrese la longitud de la diagonal menor: ";
std::cin >> diagonalMenor;
// Calcular el área del rombo
double areaRombo = calcularAreaRombo(diagonalMayor, diagonalMenor);
// Mostrar el resultado
std::cout << "El área del rombo es: " << areaRombo << std::endl;
return 0;
}
```
Este programa utiliza una función llamada `calcularAreaRombo` que recibe como parámetros las longitudes de las diagonales mayor y menor del rombo. La función calcula el área del rombo utilizando la fórmula:
Área = (diagonalMayor \* diagonalMenor) / 2
Si las diagonales son iguales, el rombo es equilátero y el área se calcula de la misma manera.
En el `main`, se pide al usuario que ingrese las longitudes de las diagonales mayor y menor, se calcula el área del rombo utilizando la función `calcularAreaRombo` y se muestra el resultado.
Recuerda que este programa asume que las diagonales son positivas y no nulas. Si se ingresa un valor negativo o cero, el programa puede producir resultados incorrectos.
def get_fanels(img, gt, mask, nlabels):
fanels = []
for i in range(nlabels):
fanel = img.copy()
fanel[gt != i] = 0
fanel = fanel * mask
fanels.append(fanel)
return np.array(fanels)
include <iostream>
int main(){
cout<<"Hello world!\n";
return 0;
}