|
Mostrar Mensajes
|
Páginas: [1] 2 3
|
1
|
Programación / Programación C/C++ / Re: [C] [unsolved] Comportamiento inesperado
|
en: 5 Abril 2022, 00:33 am
|
@Mafus, gracias por tu respuesta, el problema no es con el valor de retorno, pero leyendo un poco tu respuesta sobre como strncat funciona, ahora comprendo que mi problema estaba en la concatenación y en el no entender bien como funciona strncat.
Gracias @Mafus.
|
|
|
2
|
Programación / Programación C/C++ / [C] [solved] Comportamiento inesperado
|
en: 4 Abril 2022, 22:15 pm
|
Hola a todos. Estoy tratando de implementar el metodo str.center() que existe en Python pero en C y de paso estoy aprendiendo a programar en C, pero al borrar la linea que añade el carácter nulo al String resultante obtengo un resultado indeseado.
He estado dandole vueltas al asunto pero no me da el maní que tengo por cerebro, asi que acudo a ustedes en buscas de respuesta.
Muchas Gracias.#include <stdio.h> #include <string.h> char* center(int, char, char *); int main() { char* pstr = center(30, '*', "hola"); printf("Value: %s\t Address: %p\n", pstr , pstr ); return 0; } char* center(int width, char fc, char* str) { char output[width]; char* buffer = NULL; int cc = 0, n = 0; for(char* i = str; *i != '\0'; ++i) cc += 1; n = (width - cc) / 2; for(int j = 0; j < n; ++j) output[j] = fc; output[n] = '\0'; // Al borrar esta linea obtengo una salida incorrecta for(int i = strlen(output ); i < width ; ++i ) output [i ] = fc ; return (buffer = output); }
|
|
|
3
|
Programación / Scripting / [Python3] Me podrian explicar el funcionamiento.
|
en: 27 Junio 2020, 04:12 am
|
Hola que tal a todos, me encontre este codigo y no termino de entender input.n y los demas usos que le dan en este codigo. Crei que era sobreescritura del metodo input pero eso solo lo he visto implementado en clases no en funciones simples.
Gracias por sus respuestas
inputs = """ emanuel eduardo nuñez maliños """ def input(): try: input.n += 1 except Exception: input.n = 0 return inputs.split()[input.n] first = input() second = input() print(first, second)
[/size][/size][/size][/size]
|
|
|
4
|
Programación / Scripting / [Python3-Ayuda]
|
en: 2 Abril 2020, 02:54 am
|
Existe alguna de forma crear un script que se este siempre activo en espera de cambios de un directorio determinado. Ya que quiero realizar uno en python con dicho cometido para mover los ejecutables de archivos C a una carpeta aparte de donde tengo el código de C valga la redundancia.Se que hay programas que ya lo hacen.
Que tengo que buscar ya que no se por donde empezar.
|
|
|
6
|
Programación / Scripting / [Python3-Graficador de funciones basico]
|
en: 1 Abril 2020, 06:01 am
|
Hola que tal todos este es un muy simple graficador de funciones usando el módulo turtle.
def graficar_funciones2D(*args): """ El primer vector se tomara como las coordenadas de inicio de la gráfica si no las proporcionas por defecto es (0, 0). """ # ----------- Workspace -------------- WIDTH = 700 HEIGHT = 500 wn = Screen() wn.title("Vectores y gráficas básicas") wn.setup(WIDTH, HEIGHT) wn.screensize(WIDTH-10, HEIGHT-10) wn.bgcolor("#FFFDF9") pen = Turtle() pen.pen({"pensize": 2, "shown": False, "speed": -1}) # ----------- global variables -------------- dot_radio = 5 color = "red" wn_width = wn.window_width() wn_height = wn.window_height() """ # Descomenta esto si quieres ver un fondo cuadriculádo # ----------- grid -------------- pen.pu() pen.goto(-wn_width, wn_height) pen.seth(0) pen.pd() for i in range(0, wn_height+wn_height, 10): pen.pencolor("#daafaf") pen.pensize(1) pen.fd(wn_width) pen.up() pen.goto(-wn_width, (wn_height)-i) pen.down() pen.fd(wn_width) pen.pu() pen.goto(-wn_width, wn_height) pen.seth(270) pen.pd() for j in range(0, wn_width+wn_width, 10): pen.fd(wn_height) pen.up() pen.goto(-wn_width+j, wn_height) pen.down() pen.fd(wn_height) """ # ----------- Graph -------------- pen.up() pen.home() pen.pencolor("#090909") pen.pd() for i in range(4): pen.fd(wn_width) pen.bk(wn_width) pen.lt(90) # ----------- Points -------------- vector = args pen.up() pen.goto(vector[0][0], vector[0][1]) pen.pd() for values in vector: # pen.up() # Descomenta esta linea si no deseas ver el trazo del dibujo pen.goto(values[0], values[1]) # pen.pd() # Descomenta esta linea si no deseas ver el trazo del dibujo pen.dot(dot_radio, color) # pen.write(tuple(values), False, "right", ("tahoma", 7, "italic")) wn.listen() wn.onkeypress(lambda: wn.bye(), "space") wn.mainloop()
[/size][/size][/size]
|
|
|
9
|
Programación / Scripting / Python
|
en: 17 Marzo 2020, 06:28 am
|
¿Es necesario usar la estructura try/except cuando envió un correo usando ssl o simplemente cuando utilizo tls? ¿Cuales son las convenciones a seguir al enviar correos por medio de python?
Gracias por sus respuestas!
|
|
|
10
|
Programación / Scripting / [Python3 + turtle] = Dibujo de Pacman
|
en: 17 Marzo 2020, 04:41 am
|
from turtle import Turtle, Screen width = 600 height = 600 X = width - 10 Y = height - 10 def _turtle(): # Pantalla pantalla = Screen() pantalla.title("Pacman") pantalla.bgcolor("#254555") pantalla.setup(width=width, height=height) pantalla.colormode(255) pantalla.screensize(X, Y) pantalla.delay(0) # Tortuga turtle = Turtle() turtle.pensize(2) turtle.hideturtle() turtle.speed(0) turtle.pu() turtle.goto(-X/2, Y/2) turtle.pd() turtle.pencolor("#212140") for i in range(91): turtle.setheading(-i) turtle.fd(width/2) turtle.bk(width/2) turtle.pu() turtle.goto(X/2, Y/2) turtle.pd() for i in range(91): turtle.setheading(i) turtle.fd(-width/2) turtle.bk(-width/2) turtle.pu() turtle.goto(-X/2, -Y/2) turtle.pd() for i in range(91): turtle.setheading(i) turtle.fd(width/2) turtle.bk(width/2) turtle.pu() turtle.goto(X/2, -Y/2) turtle.pd() for i in range(91): turtle.setheading(-i) turtle.fd(-width/2) turtle.bk(-width/2) turtle.pu() turtle.home() turtle.pd() for i in range(round(width/2)): turtle.pencolor("#cfbb00") turtle.setheading(-i) turtle.fd(90) turtle.bk(90) turtle.pu() turtle.goto(-10, 45) turtle.color("#001020") turtle.pd() turtle.begin_fill() turtle.circle(10) turtle.end_fill() pantalla.exitonclick() _turtle()
|
|
|
|
|
|
|