Como hacer que un script acceda a otro?
system("python3 /home/marcelo/Documentos/deteccion/python3/test.py")
All generations.
system("python3 /home/marcelo/Documentos/deteccion/python3/test.py")
float P02RandomRange(float a, float b){
return random(a,b);
}
float dosdados()
{
float a = rand()%500;
float b = rand()%500;
return a + b;
}
#include <iostream>
using namespace std;
void main() {
int a, b, suma;
cout << "Ingrese los valores de a y b";
cin >> a >> b;
suma = a + b;
cout << "La suma es " << suma;
}
void Start()
{
timer = Time.time;
}
void OnGUI()
{
GUILayout.Label("Elapsed time " + (Time.time - timer));
}
#include <stdlib.h>
#include <stdio.h>
int main()
{
printf("Hello world!");
printf("I am a C program!");
return 0;
}
LARGE_INTEGER frequency; // ticks per second
LARGE_INTEGER t1, t2; // ticks
double elapsedTime;
// get ticks per second
QueryPerformanceFrequency(&frequency);
// start timer
QueryPerformanceCounter(&t1);
// do something
// stop timer
QueryPerformanceCounter(&t2);
// compute and print the elapsed time in millisec
elapsedTime = (t2.QuadPart - t1.QuadPart) * 1000.0 / frequency.QuadPart;
printf("Elapsed time: %f ms.\n", elapsedTime);
float P06descatarMinDados(int dados, float caras)
{
int mayor = 0;
int sum = 0;
int N = dados + 1;
int F[N];
srand(time(NULL));
for (int i = 0; i < N; i++)
{
F[i] = (rand() % (int)caras) + 1;
sum += F[i];
}
for (int i = 0; i < N; i++)
{
if (F[i] > mayor)
{
mayor = F[i];
}
}
return sum - mayor;
}
#include <stdio.h>
#include <time.h>
int main ()
{
time_t segundos;
time_t segundos_actuales;
struct tm *tiempo;
time(&segundos);
time(&segundos_actuales);
tiempo = localtime(&segundos);
printf ("La hora es: %s", asctime(tiempo));
segundos = time(NULL) - segundos;
printf("Han pasado %d segundos desde el comienzo de los tiempos.\n", (int)segundos);
return 0;
}
void Start () {
timeLeft = 1.0f;
}
void Update () {
timeLeft -= Time.deltaTime;
if(timeLeft < 0)
{
timeLeft = 1.0f;
print("time left : " + timeLeft);
}
}
float P03RandomDosDados(float caras) {
float random = rand() % (500 - 0 + 1) + 0;
return random;
}
float P05maxDados(int dados, float caras){
float valor = 0.0;
for(int i=0; i<dados; i++){
valor = max(valor, (rand() % (int)caras) + 1);
}
return valor;
}
void Update()
{
float deltaTime = Time.deltaTime;
Debug.Log(deltaTime);
}
#import <stdio.h>
#import <stdlib.h>
#import <time.h>
#import <math.h>
int main(){
int dados = 2;
float caras = 6;
float impulso = 0;
//generar un numero aleatorio entre 1 y caras
srand(time(NULL));
for(int i = 0; i < dados; i++){
float r = rand() % (int)caras + 1;
impulso += r;
}
printf("Numero de dados: %d\n", dados);
printf("Numero de caras por dado: %d\n", (int)caras);
printf("Impulso: %f\n", impulso);
system("pause");
return 0;
}
void Start() {
//tiempo transcurrido en unity
print(Time.time);
}
// Example program
#include <iostream>
#include <string>
#include <chrono>
//https://stackoverflow.com/questions/22387586/measuring-execution-time-of-a-function-in-c
int main()
{
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
// do something
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end-start;
std::time_t end_time = std::chrono::system_clock::to_time_t(end);
std::cout << "finished computation at " << std::ctime(&end_time)
<< "elapsed time: " << elapsed_seconds.count() << "s\n";
}
#include <iostream>
#include <time.h>
using namespace std;
int main ()
{
time_t timer;
struct tm y2k = {0};
double seconds;
y2k.tm_hour = 0; y2k.tm_min = 0; y2k.tm_sec = 0;
y2k.tm_year = 100; y2k.tm_mon = 0; y2k.tm_mday = 1;
time(&timer); /* get current time; same as: timer = time(NULL) */
seconds = difftime(timer,mktime(&y2k));
cout << seconds << " seconds since January 1, 2000 in the current timezone" << endl;
return 0;
}
float P04RandomVariosDados(int dados, float caras)
{
float total = 0;
for (int i = 0; i < dados; i++)
{
total += floor(1 + (rand() % (int)caras));
}
return total;
}
#include <iostream>
using namespace std;
int main()
{
int a;
cin >> a;
cout << a+2 << endl;
}
void OnTriggerEnter(Collider other){
if(other.gameObject.name == "Player"){
float tiempo_transcurrido = Time.timeSinceLevelLoad;
print("Tiempo transcurrido: " + tiempo_transcurrido);
}
}
#include <iostream>
#include <chrono>
#include <ctime>
int main()
{
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
std::cout << "waiting for the end" << std::endl;
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end-start;
std::time_t end_time = std::chrono::system_clock::to_time_t(end);
std::cout << "finished computation at " << std::ctime(&end_time)
<< "elapsed time: " << elapsed_seconds.count() << "s\n";
}
float P06descatarMinDados(int dados, float caras){
float sum = 0;
int min = 0;
int i;
for(i = 0; i < dados + 1; i++){
int current = (rand() % caras) + 1;
if(i == 0) min = current;
if(current <= min) min = current;
sum += current;
}
return sum - min;
}
void tiempo(){
const int numFrames = 100;
float deltaTime[numFrames];
int frameIndex = 0;
float frameTime = 0.0f;
float lastTime = 0.0f;
float fps = 0.0f;
for (int i = 0; i < numFrames; i++) {
//Tiempo actual del frame
float startTime = Time.realtimeSinceStartup;
//Tiempo del ultimo frame
deltaTime[frameIndex++] = startTime - lastTime;
//Si el frameIndex llega al limite vuelve al comienzo
if (frameIndex >= numFrames) frameIndex = 0;
//Guarda el tiempo del ultimo frame
lastTime = startTime;
float count = 0;
for (int j = 0; j < numFrames; j++)
count += deltaTime[j];
//calculo del tiempo de los ultimos frames
frameTime = count/num
float P03RandomDosDados(float caras){
srand(time(NULL));
int a = rand()%caras+1;
int b = rand()%caras+1;
return a+b;
}
float P01FuerzaFija(){
return 500;
}
float P01FuerzaFija(){
return 500;
};
float P02RandomRange(){
return Random.Range(200, 500);
};
float P03RandomDosDados(float faces){
return Random.Range(0, 6) + Random.Range(0, 6);
};
float P04RandomVariousDice(int dice, float faces){
int sum = 0;
for(int i = 0; i < dice; i++){
sum += Random.Range(0, 6);
}
return sum;
};
float P05maxDice(int dice, float faces){
int max = 0;
for(int i = 0; i < dice; i++){
int dado = Random.Range(0, 6);
if(dado > max){
max = dado;
}
}
return max;
};
float P06discardMinDice(int dice, float faces){
int min = 6;
int sum = 0;
void P02RandomRange(){
int r = random(200, 500);
return r;
}
P02RandomRange()
void Start()
{
InvokeRepeating("BallCreator", 1.0f, 1.0f);
}
void BallCreator()
{
GameObject ball = Instantiate(Ball, transform.position, transform.rotation);
Rigidbody rbBall = ball.GetComponent<Rigidbody>();
rbBall.AddForce(0, 0, P01FuerzaFija());
}
float P01FuerzaFija()
{
return 500;
}
#include <iostream>
void main()
{
int a;
while(true)
{
cout<<"hola";
}
}
class Timer
{
private:
double startTime;
public:
void setTime();
double getTime();
};
void Timer::setTime()
{
startTime = glfwGetTime();
}
double Timer::getTime()
{
return glfwGetTime() - startTime;
}
void setup() {
Serial.begin(9600);
pinMode(A0, INPUT);
}
void loop() {
float P02input = analogRead(A0);
Serial.println(P02input);
}
int main(){
char carta[]={1,2,3,4,5,6,7,8,9,10,11,12,13};
carta[13] = NULL;
int jugador = 0;
int ai = 0;
for(int i = 0; i < 13; i++){
//jugador
int carta_jugador = rand() % 13;
cout << "carta jugador: " << carta[carta_jugador] << endl;
jugador += carta[carta_jugador];
//ai
int carta_ai = rand() % 13;
cout << "carta ai: " << carta[carta_ai] << endl;
ai += carta[carta_ai];
}
if(jugador > ai){
cout << "Gano jugador" << endl;
}
else if(ai > jugador){
cout << "Gano ai" << endl;
}
void Update()
{
// Get the elapsed time
float time = Time.time;
// Print the elapsed time
Debug.Log(time);
}
#include <iostream>
int main()
{
std::cout << "Hello World!\n";
}
#include <iostream>
#include <ctime>
using namespace std;
int dado1D6(){
return rand()%6+1;
}
float variosDados(int dados, float caras){
float valor = 0;
for(int i = 0; i < dados; i++)
valor += dado1D6();
return valor/caras;
}
int main(){
srand(time(0));
cout << variosDados(4, 6) << endl;
}
float P01FuerzaFija(){
return 500.0f;
}
float P02RandomRange(){
return static_cast <float> (rand()) / (static_cast <float> (RAND_MAX/(500-200))) + 200;
}
float P03RandomDosDados(float faces){
float dado1 = static_cast <float> (rand()) / (static_cast <float> (RAND_MAX/(faces)));
float dado2 = static_cast <float> (rand()) / (static_cast <float> (RAND_MAX/(faces)));
return dado1 + dado2;
}
float P04RandomVariousDice(int dice, float faces){
float suma=0;
for (int i = 0; i < dice; ++i)
{
suma += P03RandomDosDados(faces);
}
return suma;
}
float P05maxDice(int dice, float faces){
float max;
max =
int P02RandomRange(){
return rand()%(500-200+1)+200;
}
int P06descatarMinDados(int dados, float caras){
int suma = 0;
int min_dado = caras;
int i;
for(i=0; i < dados + 1; i++){
int nuevo_dado = rand() % caras + 1;
if (nuevo_dado < min_dado)
min_dado = nuevo_dado;
suma += nuevo_dado;
}
suma -= min_dado;
return suma;
}
float time = Time.time;
float deltaTime = Time.deltaTime;
Debug.Log(time);
Debug.Log(deltaTime);
int P05maxDados(int dados, float caras){
int max = 0;
for(int i =0; i<dados; i++){
int num = rand()%caras;
if(num > max){
max = num;
}
}
return max + 1;
}
float P01FuerzaFija()
{
return 500;
}
float P02RandomRange()
{
return Random.Range(200, 500);
}
float P03RandomDosDados(float faces)
{
return (Random.Range(1, faces) + Random.Range(1, faces));
}
float P04RandomVariousDice(int dice, float faces)
{
float sum = 0;
for(int i = 0; i < dice; i++)
{
sum += Random.Range(1, faces);
}
return sum;
}
float P05maxDice(int dice, float faces)
{
float max = 0;
float temp = 0;
for(int i = 0; i < dice; i++)
{
temp = Random.Range(1, faces);
if (temp > max)
max = temp;
}
return max;
}
float P06discardMinDice(int
float startTime;
float timeElapsed;
void someFunction()
{
startTime = Time.time;
/*
...your code here...
*/
timeElapsed = Time.time - startTime;
Debug.Log("Time elapsed: " + timeElapsed);
}
#include "stdio.h"
#include <iostream>
int main(){
return 0;
}
// C++
#include <iostream>
#include <chrono>
#include <thread>
// sleep for a while:
std::this_thread::sleep_for(std::chrono::seconds(2));
// print elapsed time:
auto start = std::chrono::steady_clock::now();
// do something:
auto end = std::chrono::steady_clock::now();
std::cout << "Elapsed time in nanoseconds : "
<< std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count()
<< " ns" << std::endl;
float P05maxDice(int dice, float faces)
{
float max = 0;
int i = 0;
while (i < dice)
{
float roll = random(faces);
if (roll > max)
{
max = roll;
}
i++;
}
return max;
}
float P01FuerzaFija()
{
return 500.0f;
}
float P02RandomRange()
{
//rand() we use this within a range
int random = rand() % 500;
random += 200;
return random;
}
float P03RandomDosDados(float faces)
{
float random1 = (rand() % (int)faces) + 1;
float random2 = (rand() % (int)faces) + 1;
float result = random1 + random2;
if (result > 500)
{
result = 500;
}
return result;
}
float P04RandomVariousDice(int dice, float faces)
{
float result = 0.0f;
for (int i = 0; i < dice; i++)
{
result += (rand() % (int)faces) + 1;
}
if (result > 500)
{
result = 500;
}
return result;
#include "stdafx.h"
#include <iostream>
#include <Windows.h>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
cout << "Hello word!" << endl;
Sleep(1000);
return 0;
}
#include <time.h>
#include <stdio.h>
#define BILLION 1000000000L;
int main()
{
struct timespec start, stop;
double accum;
if( clock_gettime( CLOCK_REALTIME, &start) == -1 ) {
perror( "clock gettime" );
exit( EXIT_FAILURE );
}
/* Do busy work. */
accum = 0;
for( int i=0; i<100000000; ++i )
accum += i*i;
if( clock_gettime( CLOCK_REALTIME, &stop) == -1 ) {
perror( "clock gettime" );
exit( EXIT_FAILURE );
}
printf( "%lf\n", ( stop.tv_sec - start.tv_sec ) +
(double)( stop.tv_nsec - start.tv_nsec )/(double)BILLION );
return 0;
}
auto t_start = std::chrono::high_resolution_clock::now();
// code
auto t_end = std::chrono::high_resolution_clock::now();
std::cout << "Elapsed time: " << std::chrono::duration<double, std::milli>(t_end-t_start).count() << " ms\n";
int P03RandomDosDados(int caras){
// Numpy's randint, low is inclusive and high is exclusive
randint(0, caras)
}
P03RandomDosDados(500)`
using UnityEngine;
using System.Collections;
public class PrintTime : MonoBehaviour
{
private float startTime;
void Start()
{
startTime = Time.time;
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
float time = Time.time - startTime;
print("Time: " + time);
}
}
}
//use a timer to calculate the time
Timer timer;
void Start(){
timer = gameObject.AddComponent<Timer>();
timer.Duration = 10;
timer.Run();
}
void Update(){
Debug.Log("Time: " + timer.Elapsed);
}
/*
// In the beginning of the game
private float startTime;
private float ellapsedTime;
void Start()
{
startTime = Time.time;
}
// In each frame
void Update()
{
ellapsedTime = Time.time - startTime;
Debug.Log("Elapsed time: " + ellapsedTime);
}
*/
float time = Time.time;
float P03RandomDosDados(float caras) {
float dado1, dado2;
dado1 = rand() % (500 + 1); // [0,500]
dado2 = rand() % (500 + 1); // [0,500]
return dado1 + dado2;
}
float P03RandomDosDados(float caras)
{
float dado1 = (rand() % int(caras)) + 1;
float dado2 = (rand() % int(caras)) + 1;
float suma = dado1 + dado2;
return suma;
}
int f = 0;
int startTime = 0;
int endTime = 0;
void Start () {
startTime = Time.time;
}
void Update () {
if (f == 0) {
endTime = Time.time;
Debug.Log(endTime-startTime);
f = 1;
}
}
// Print time elapsed since start
float time = myTimer.GetElapsedTime();
std::cout << "Time: " << time << "s\n";
float P03RandomDosDados(float caras) {
return (0 + caras) + ((rand() % 500) + caras);
}
void Player::move(int x, int y){
this->x += x;
this->y += y;
}
void Player::jump(){
//Jump animation
}
void Player::shoot(){
//Shoot animation
}
int tiempo = 0;
void Update () {
tiempo += Time.deltaTime;
}
void OnGUI () {
GUI.Label(new Rect(10, 10, 100, 20), new GUIContent(""+tiempo));
}
int P05maxDados(int dados, float caras){
int max = 0;
int elDado = 0;
for(int i = 0; i < dados; i++){
elDado = random(caras) + 1;
if(elDado > max){
max = elDado;
}
}
return max;
}
#include <time.h>
void ShowTime()
{
time_t t = time(NULL);
tm tl = *localtime(&t);
cout << tl.tm_hour << ":" << tl.tm_min << ":" << tl.tm_sec << endl;
}
void PrintTime() {
float time = GameTime.GetTime();
Debug.Log("Time Elapsed: " + time);
}
#include <iostream>
#include <chrono>
#include <thread>
int main()
{
using namespace std::this_thread; // sleep_for, sleep_until
using namespace std::chrono; // nanoseconds, system_clock, seconds
auto start = std::chrono::system_clock::now();
sleep_for(std::chrono::seconds(1));
auto end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end-start;
std::time_t end_time = std::chrono::system_clock::to_time_t(end);
std::cout << "finished computation at " << std::ctime(&end_time)
<< "elapsed time: " << elapsed_seconds.count() << "s\n";
}
int P05maxDados(int dados, float caras){
int sum = 0;
int max = 0;
for (int i = 0; i < dados; i++){
int current = (int)(rand() / (float) RAND_MAX * (caras - 1) + 1);
sum += current;
if (current > max){
max = current;
}
}
cout << "Sum: " << sum << " Max: " << max << endl;
return 0;
}
float P04RandomVariosDados(int dados, float caras)
{
int suma = 0;
for (int i = 0; i < dados; i++)
{
suma += rand() % caras + 1;
}
return suma;
}
float P03RandomDosDados()
{
float random = (rand() % 500);
return random;
}
#include <stdlib.h>
#include <time.h>
// Return random number between 0 and 500
float P02RandomRange() {
return rand() % 500;
}
// Return random number between 0 and 500
float P03RandomDosDados(float faces) {
return (rand() % faces) + (rand() % faces);
}
// Return random number between 0 and 500
float P04RandomVariousDice(int dice, float faces) {
float result = 0;
for(int i = 0; i < dice; i++) {
result += rand() % faces;
}
return result;
}
// Return random number between 0 and 500
float P06discardMinDice(int dice, float faces) {
int min = 0;
float result = 0;
for(int i = 0; i < dice + 1; i++) {
int r = rand() % faces;
if(i == 0) {
min = r;
}
else if(
cout<<"Tiempo transcurrido: " << tiempo_ms/1000.0 <<" segundos";
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
int main() {
int day, month, year;
char date[15];
int day2, month2, year2;
char date2[15];
scanf("%s", date);
sscanf(date, "%2d/%2d/%4d", &day, &month, &year);
scanf("%s", date2);
sscanf(date2, "%2d/%2d/%4d", &day2, &month2, &year2);
int time = year * 365 * 24 * 60 * 60 + month * 30 * 24 * 60 * 60 + day * 24 * 60 * 60;
int time2 = year2 * 365 * 24 * 60 * 60 + month2 * 30 * 24 * 60 * 60 + day2 * 24 * 60 * 60;
int diff = abs(time - time2);
printf
int P05maxDados(int dados, float caras)
{
if (dados > 0)
{
int result = rand() % (int) caras + 1;
int max = result;
for (int i = 1; i < dados; i++)
{
result = rand() % (int) caras + 1;
if (max < result)
max = result;
}
return max;
}
else
return -1;
}
float descartar_menor(int dados, float caras){
float suma = 0;
int menor = int(caras+1);
int random = 0;
int dado = 0;
while(dado < dados){
random = rand()%int(caras)+1;
if(random < menor){
menor = random;
}
suma += random;
dado++;
}
return suma - menor;
}
while (true)
{
cout << UnityGetTime( ) << endl;
}
float deltaTime = Time.deltaTime;
Debug.Log("Time since last frame: " + deltaTime);
float P01FuerzaFija(float tiempo)
{
float fuerza = 0;
float f = 500;
if (fuerza = f)
{
fuerza = tiempo;
return fuerza;
}
else
{
return fuerza;
}
}
int maxDados(int dados, float caras) {
srand(time(NULL));
int max = 0;
for(int i = 0; i < dados; i++) {
int dado = random(1, caras);
max = (dado > max) ? dado : max;
}
return max;
}
maxDados(3, 6)
void P03RandomDosDados(float caras)
{
float tira_uno = rand() % caras;
float tira_dos = rand() % caras;
float suma = tira_uno + tira_dos;
cout << "Tirando dos dados..." << endl;
cout << "Tira UNO: " << tira_uno << endl;
cout << "Tira DOS: " << tira_dos << endl;
cout << "Suma: " << suma << endl;
}
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