#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
# -*- 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
<div class="heart">
<div class="heart-main">
<div class="heart-line">
<div class="heart-line1"></div>
<div class="heart-line2"></div>
<div class="heart-line3"></div>
<div class="heart-line4"></div>
<div class="heart-line5"></div>
<div class="heart-line6"></div>
<div class="heart-line7"></div>
<div class="heart-line8"></div>
<div class="heart-line9"></div>
<div class="heart-line10"></div>
<div class="heart-line11"></div>
<div class="heart-line12"></div>
<div class="heart-line13"></div>
<div class="heart-line14"></div>
<div class="heart-line15"></div>
<div class="heart-line16"></div>
<div class="heart-line17"></div>
A = {1,2,3,4,5}
B = {4,5,6,7,8}
A | B
def vosk(question, answer):
#Vosk
return answer
#include <stdio.h>
float avg(int nums[ ], int n) {
int i, sum = 0;
for(i = 0; i < n; i++) {
sum += nums[i];
}
return ((float)sum)/n;
}
int main() {
int nums[] = {1, 2, 3, 4, 5};
printf("%f", avg(nums, 5));
}
import numpy as np
def add_matrix_and_vector(x, y):
return x + y
matrix = np.array([[1, 2], [3, 4]])
vector = np.array([6, 7])
add_matrix_and_vector(matrix, vector)
Please keep input under 1000 characters
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);
}
def backtest_aapl(window):
b = backtesting.Backtest(aapl['Close'], aapl['Close'].rolling(window).mean(), signal_type='stochastic_oscillator', short_window=window, long_window=2*window)
return b.signal
def difficulty(player_level, quest_type, equipment):
if player_level < 10:
return 1
elif player_level < 20:
return 2
elif player_level < 30:
return 3
elif player_level < 40:
return 4
elif player_level < 50:
return 5
elif player_level < 60:
return 6
elif player_level < 70:
return
UPDATE Projects SET name = TRIM(name);
<div class="heart">
<div class="heart-main">
<div class="heart-line">
<div class="heart-line1"></div>
<div class="heart-line2"></div>
<div class="heart-line3"></div>
<div class="heart-line4"></div>
<div class="heart-line5"></div>
<div class="heart-line6"></div>
<div class="heart-line7"></div>
<div class="heart-line8"></div>
<div class="heart-line9"></div>
<div class="heart-line10"></div>
<div class="heart-line11"></div>
<div class="heart-line12"></div>
<div class="heart-line13"></div>
<div class="heart-line14"></div>
<div class="heart-line15"></div>
<div class="heart-line16"></div>
<div class="heart-line17"></div>
def serie(resistencias):
total = 0
for resistencia in resistencias:
total += resistencia
return total
def paralelo(resistencias):
total = 0
for resistencia in resistencias:
if resistencia == 0:
return 0
total += 1 / resistencia
return 1 / total
def total(resistencias, tipo):
if tipo == "serie":
return serie(resistencias)
elif tipo == "paralelo":
return paralelo(resistencias)
else:
print("Tipo de resistencia no reconocida")
return None
resistencias = []
while True:
cantidad = int(input("Ingrese la cantidad de resistencias: "))
if cantidad > 0:
break
print("Ingrese una cantidad positiva")
for i in range(cantidad):
while True:
categories.of.variable <- function(x){
return(length(levels(x)))
}
var products = [
{ name: 'Galletas', description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.' },
{ name: 'Bebidas', description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.' },
{ name: 'Comida', description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.' },
{ name: 'Papas', description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.' },
{ name: 'Tortas', description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.' },
]
var carousel = document.getElementById('carousel');
var html = '';
html += '<div class="products">'
for (var i = 0; i < products.length; i++) {
html += '<div class="product">';
html += '<
def login(user, password):
while(True):
i = 0
while(i<3):
if(user == 'a' and password == 'b'):
print('Welcome')
return True
else:
print('Wrong username or password')
i = i + 1
user = input('User: ')
password = input('Password: ')
print('You have exceeded the maximum number of attempts')
return False
login('a', 'b')
++
void intercambiar(int *a, int *b)
{
int temp;
temp = *a;
*a = *b;
*b = temp;
}
void main()
{
int a, b;
cout << "a = "; cin >> a;
cout << "b = "; cin >> b;
intercambiar(&a, &b);
cout << "a = " << a << endl;
cout << "b = " << b << endl;
}
SELECT SUM(Total) FROM Orders WHERE OrderDate LIKE "1998-01-%" AND EmployeeID=5;
import unittest
class TestCadena(unittest.TestCase):
def test_upper(self):
self.assertEqual('foo'.upper(), 'FOO')
def test_isupper(self):
self.assertTrue('FOO'.isupper())
self.assertFalse('Foo'.isupper())
def test_split(self):
s = 'hello world'
self.assertEqual(s.split(), ['hello', 'world'])
# check that s.split fails when the separator is not a string
with self.assertRaises(TypeError):
s.split(2)
if __name__ == '__main__':
unittest.main()
def difficulty(player_level, quest_type, equipment):
if player_level < 10:
return 1
elif player_level < 20:
return 2
elif player_level < 30:
return 3
elif player_level < 40:
return 4
elif player_level < 50:
return 5
elif player_level < 60:
return 6
elif player_level < 70:
return
#include <iostream>
int main() {
int suma = 0;
for (int i = 0; i < 200; ++i) {
if(i % 2 != 0)
suma += i;
}
std::cout << suma << std::endl;
return 0;
}
Script
function processes(arr) {
var obj = {};
var p1_count = 0;
var p2_count = 0;
var a = 0;
var b = 0;
for (var i = 0; i < arr.length; i++) {
if (arr[i] === "PROC1") {
p1_count += 1;
a = p1_count;
} else {
p2_count += 1;
b = p2_count;
}
if (a === b) {
obj[arr[i]] = b;
a = 0;
b = 0;
}
}
return obj;
}
processes(["PROC1", "PROC1", "PROC1", "PROC2", "PROC2", "PROC2"]);
function saludo(idioma) {
switch (idioma) {
case 'aleman':
return 'Guten Tag!';
case 'mandarin':
return 'Ni Hao!';
case 'ingles':
return 'Hello!';
default:
return 'Hola!';
}
}
#include <stdio.h>
float avg(int nums[ ], int n) {
int i, sum = 0;
for(i = 0; i < n; i++) {
sum += nums[i];
}
return ((float)sum)/n;
}
int main() {
int nums[] = {1, 2, 3, 4, 5};
printf("%f", avg(nums, 5));
}
public class Movimiento
{
public bool MovimientoBasico(int[] posicion, int[] destino)
{
if ( destino == posicion )
{
return false;
}
else if ( destino[0] >= posicion[0] )
{
posicion[0] ++;
}
else if ( destino[0] <= posicion[0] )
{
posicion[0] --;
}
else if ( destino[1] >= posicion[1] )
{
posicion[1] ++;
}
else if ( destino[1] <= posicion[1] )
{
posicion[1] --;
}
else
{
return false;
}
return true;
}
}
#include <iostream>
int main() {
int suma = 0;
for (int i = 0; i < 200; ++i) {
if(i % 2 != 0)
suma += i;
}
std::cout << suma << std::endl;
return 0;
}
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)
tmp_file.close
#include <stdio.h>
#include <stdlib.h>
int main(){
int m,n;
scanf("%d",&m);
scanf("%d",&n);
if ((m>=1 && m<=50) && (n>=1 && n<=50)){
for (int i=0; i<n; i++){
for (int j=0; j<m; j++){
printf("*");
}
printf("\n");
}
}
return 0;
}
#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;
}
Script
function processes(arr) {
var obj = {};
var p1_count = 0;
var p2_count = 0;
var a = 0;
var b = 0;
for (var i = 0; i < arr.length; i++) {
if (arr[i] === "PROC1") {
p1_count += 1;
a = p1_count;
} else {
p2_count += 1;
b = p2_count;
}
if (a === b) {
obj[arr[i]] = b;
a = 0;
b = 0;
}
}
return obj;
}
processes(["PROC1", "PROC1", "PROC1", "PROC2", "PROC2", "PROC2"]);
#include <iostream>
using namespace std;
int main() {
float diff_d1, diff_d2, diff_d3;
do {
cout << "Inserire il valore dei dadi del difensore:\n";
cin >> diff_d1 >> diff_d2 >> diff_d3;
} while (diff_d1 < 0 || diff_d1 > 6 || diff_d2 < 0 || diff_d2 > 6 || diff_d3 < 0 || diff_d3 > 6 || (diff_d1 == 0 && diff_d2 == 0 && diff_d3 == 0));
}
#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
def algoritmo_genetico(valor_inicial, valor_final, formacion_de_parejas, numero_de_generaciones, probabilidad_de_cruzamiento, probabilidad_de_mutacion):
# Inicializamos la poblacion
poblacion = []
for i in range(0, numero_de_generaciones):
poblacion.append([])
for j in range(0
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)
import unittest
class TestCadena(unittest.TestCase):
def test_upper(self):
self.assertEqual('foo'.upper(), 'FOO')
def test_isupper(self):
self.assertTrue('FOO'.isupper())
self.assertFalse('Foo'.isupper())
def test_split(self):
s = 'hello world'
self.assertEqual(s.split(), ['hello', 'world'])
# check that s.split fails when the separator is not a string
with self.assertRaises(TypeError):
s.split(2)
if __name__ == '__main__':
unittest.main()
import numpy as np
def add_matrix_and_vector(x, y):
return x + y
matrix = np.array([[1, 2], [3, 4]])
vector = np.array([6, 7])
add_matrix_and_vector(matrix, vector)
def tiempos(h, m):
h = h*60
return h + m
h = 17
m = 30
tiempo = tiempos(h, m)
print(tiempo)
def drawArrow(turtle, size):
for i in range(0, 4):
turtle.forward(size)
turtle.right(90)
drawArrow(turtle, 100)
Script
function processes(arr) {
var obj = {};
var p1_count = 0;
var p2_count = 0;
var a = 0;
var b = 0;
for (var i = 0; i < arr.length; i++) {
if (arr[i] === "PROC1") {
p1_count += 1;
a = p1_count;
} else {
p2_count += 1;
b = p2_count;
}
if (a === b) {
obj[arr[i]] = b;
a = 0;
b = 0;
}
}
return obj;
}
processes(["PROC1", "PROC1", "PROC1", "PROC2", "PROC2", "PROC2"]);
include <iostream>
int main(){
cout<<"Hello world!\n";
return 0;
}
A = {1,2,3,4,5}
B = {4,5,6,7,8}
A | B
def big_vowels(sentence, word):
#include <iostream>
using namespace std;
int main() {
float diff_d1, diff_d2, diff_d3;
do {
cout << "Inserire il valore dei dadi del difensore:\n";
cin >> diff_d1 >> diff_d2 >> diff_d3;
} while (diff_d1 < 0 || diff_d1 > 6 || diff_d2 < 0 || diff_d2 > 6 || diff_d3 < 0 || diff_d3 > 6 || (diff_d1 == 0 && diff_d2 == 0 && diff_d3 == 0));
}
Script
function createDashboardForm() {
var form = document.createElement('form');
//set form attributes
form.style.padding = '20px';
form.style.border = '1px dashed #000';
form.style.width = '350px';
//create a title
var title = document.createElement('h1');
title.innerHTML = 'Sign up for our newsletter';
//create a description
var description = document.createElement('p');
description.innerHTML = 'Enter your information below to receive our free newsletter.';
//create inputs
var nameInput = document.createElement('input');
nameInput.setAttribute('type', 'text');
nameInput.setAttribute('placeholder', 'Name');
nameInput.style.display = 'block';
nameInput.style.marginBottom = '10px';
var emailInput = document.createElement('input');
emailInput.setAttribute('type', 'email');
emailInput.setAttribute('placeholder', 'Email');
email
# -*- 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
You can use the following code to get the desired output.
function add(a, b) {
return a + b;
}
function subtract(a, b) {
return a - b;
}
function multiply(a, b) {
return a *
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.
++
void intercambiar(int *a, int *b)
{
int temp;
temp = *a;
*a = *b;
*b = temp;
}
void main()
{
int a, b;
cout << "a = "; cin >> a;
cout << "b = "; cin >> b;
intercambiar(&a, &b);
cout << "a = " << a << endl;
cout << "b = " << b << endl;
}
#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 chatbot() {
while(true) {
string userinput;
getline(cin, userinput);
if(userinput == "hello")
cout << "Hello!" << endl;
else if(userinput == "why are you so stupid?")
cout << "because i am a bot" << endl;
else
cout << "i dont understand" << endl;
}
}
nclude <iostream>
#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glext.h>
#include <gl/glut.h>
#include <gl/glaux.h>
#include <gl/glx.h>
#include <gl/glxext.h>
#include <gl/wglext.h>
plt.figure(figsize = (12, 4))
plt.bar(data.index, data['nutri'], color = 'darkblue', label = 'nutri')
plt.bar(data.index, data['mineral'], color = 'brown', label = 'mineral')
plt.title('Comparison of Nutrient and Mineral Content')
plt.xlabel('Nutrient|Mineral')
plt.ylabel('Amount')
plt.legend()
plt.show()
import mysql.connector
import hashlib
import sys
def login(username, password):
"""
"""
# Create connection
mydb = mysql.connector.connect(
host="localhost",
user="user",
passwd="pass",
database="mydatabase"
)
# Create cursor to execute queries
cursor = mydb.cursor()
# Create query and execute
query = f"SELECT * FROM login WHERE username = '{username}'"
cursor.execute(query)
# Fetch all results
result = cursor.fetchall()
# Check if query was successful
if result == []:
print("Invalid username and/or password")
return
# Check if user exists
if len(result) != 1:
print("ERROR: More than one user exists")
return
# Check if password is correct
# Load password from database
db_password = result[0][1]
# Encrypt password
#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;
}
++
bool S1 = 0;
bool S2 = 0;
bool S3 = 0;
bool S4 = 0;
bool S5 = 0;
bool S6 = 0;
bool S7 = 0;
bool S8 = 0;
bool S9 = 0;
bool S10 = 0;
bool S11 = 0;
bool S12 = 0;
bool S13 = 0;
bool S14 = 0;
bool S15 = 0;
bool S16 = 0;
void setup() {
pinMode(S1, OUTPUT);
pinMode(S2, OUTPUT);
pinMode(S3, OUTPUT);
pinMode(S4, OUTPUT);
pinMode(S5, OUTPUT);
pinMode(S6, OUTPUT);
pinMode(S7, OUTPUT);
pinMode(S8, OUTPUT);
pinMode(S9, OUTPUT);
pinMode(S10, OUTPUT);
pinMode(S11, OUTPUT);
pinMode(S12
/*
Tema: Presentacion de animal
Autor: @ricardoifc
*/
String[] frases = {
"Bienvenidos a mi presentación.",
"Hoy les voy a hablar de gatos",
"Los gatos son animales muy inteligentes."
};
PImage[] imagenes;
int contador = 0;
void setup() {
size(640, 480);
imagenes = new PImage[5];
for (int i = 0; i < imagenes.length; i++) {
String numero = str(i+1);
imagenes[i] = loadImage("gato" + numero + ".jpg");
}
}
void draw() {
background(0);
image(imagenes[contador], 0, 0);
textFont(createFont("Arial", 32));
fill(255);
text(frases[contador], 40, 40, 600, 400);
}
void mousePressed() {
public interface FiguraGeometrica {
double calcularArea();
double calcularPerimetro();
}
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)
# Add a rectangle
color = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255) )
pygame.draw.rect(screen, color, [random.randint(0, 200), random.randint(0, 200), 50, 50])
def hipotenusa(a, b):
return a**2 + b**2
hipotenusa(3, 4)
A:
Python 3.6+
The ** operator is a binary operator that can be used to raise a number to a power. It is equivalent to the ** operator in Python 2.7+, but is more readable and more efficient.
>>> 3 ** 2