|
Mostrar Temas
|
Páginas: [1]
|
2
|
Programación / Java / Suma de dos matrices - Me devuelve "[[D@7d4991ad"
|
en: 31 Marzo 2019, 23:54 pm
|
Hice un intento de programa para sumar dos matrices (soy novato en java) , el problema es que el resultado me devuelve un "[[D@7d4991ad" y no se como podria solucionarlo. cualquier ayuda es bienvenida. package bidimensional; import java.util.Scanner; public class Bidimensional { private double[][] matriz; private int renglones; private int columnas; public Bidimensional(int renglones, int columnas) { // constructor y pido el ingreso de valores a matrices Scanner entrada = new Scanner (System. in); this.matriz = new double [renglones][columnas]; for(int i=0 ; i<renglones; i++) { for(int j=0; j<columnas; j++) { System. out. print("Ingresar el numero de matriz ["+i +":"+j +"]: "); matriz[i][j]=entrada.nextDouble(); } } } public double[][] suma(Bidimensional m2) // operacion de suma { for(int i=0; i<2; i++) { for(int j=0; j<2; j++) { matriz[i][j]=matriz[i][j]+m2.matriz[i][j]; } } return matriz; } }
MAIN: package testBidimensional; import bidimensional.Bidimensional; public class TestBidimensional { public static void main (String[] args ) { // TODO Auto-generated method stub Bidimensional matrices1 = new Bidimensional(2,2); Bidimensional matrices2 = new Bidimensional(2,2); System. out. println("Suma: "+matrices1. suma(matrices2 )); } }
|
|
|
3
|
Programación / ASM / TMR0 como contador por pulsos (P16F628A)
|
en: 28 Septiembre 2018, 00:16 am
|
Buenas gente, soy nuevo en el foro, y vengo con una duda, un poco fácil para ustedes. Verán estoy haciendo un trabajo para la facultad, sencillo, somos nuevos en assembler, y me piden por un DISPLAY de 7 segmentos contar automaticamente, en hexadecimal, hasta 15 (F), y despues decrementar también automáticamente, el problema surge que me piden entre cada cambio de display un retardo de 1 segundo hecho únicamente con el TMR0, y a la vez pausar y reanudar el programa mediante un pulsador en RB0. Nunca hice retardos por el TMR0, solo los hacía mediante loops de contadores contando los ciclos de maquina etc... Verán, lo que hice fue el programa beta que cuento hasta 15 y decremento, automaticamente, con un retardo de 1 segundo, tambien llegue a hacer una pausa. Lo que me faltaría saber es el loop para continuar y reanudar, lo intente hacer btfss y btfsc pero no le encuentro la vuelta. tambien hacer un retardo unicamente con el TMR0. Hasta ahora, si presiono RB0 se para el programa pero no lo puedo reanudar, les paso el .asm. #include <p16f628a.inc>
Contador equ 0x20 AuxStatus equ 0x21 AuxW equ 0x22 Contador3 equ 0x24 CONT EQU 0x27 CONT2 EQU 0x28 CONT3 EQU 0x29
org 0 goto Configuracion org 0x04 Interrupcion: btfsc PORTB,0 goto $ bcf INTCON,GIE ;INHABILITO INTERRUPCIONES GLOBALES bcf INTCON,INTF ;BAJO EL FLAG DE INTERRUPCION DE RB0 bsf INTCON,GIE ;HABILITO INTERRUPCIONES GLOBALES movwf AuxW ;GUARDO EL CONTENIDO DE W movfw STATUS movwf AuxStatus ;GUARDO EL CONTENIDO DEL STATUS movwf STATUS movfw AuxW retfie
Configuracion: bsf INTCON,GIE ;HABILITO INTERRUPCIONES GLOBALES bsf INTCON,INTE ;HABILITO INTERRUPCIONES POR RB0 bsf STATUS,RP0 ;CAMBIO A BANCO 1 clrf TRISB ;SETEA TODOS LOS BITS DEL TRISB EN 0 bsf TRISB,0 ;RB0 COMO ENTRADA bcf STATUS,RP0 ;CAMBIO A BANCO 0 movlw B'10000000' ;EL DISPLAY INICIA EN 0 movwf PORTB clrf Contador ;INICIALIZO EL CONTADOR EN 0
Inicio: movlw d'15 movwf Contador3 incf Contador,1 ;SI FUE PULSADO, SE INCREMENTA EL CONTADOR EN 1 movfw Contador ;SE PASA EL VALOR DE CONTADOR A W call Display movwf PORTB call delay_1s decfsz Contador3,f goto $-.6 ;HASTA CALL PRESION movlw d'15 movwf Contador3 decf Contador,1 movfw Contador call Display movwf PORTB call delay_1s decfsz Contador3,f goto $-.6 ;HASTA CALL PRESION goto Inicio
Display: addwf PCL,1 retlw B'01111110' ;NUMERO 0 retlw B'00001100' ;NUMERO 1 retlw B'10110110' ;NUMERO 2 retlw B'10011110' ;NUMERO 3 retlw B'11001100' ;NUMERO 4 retlw B'11011010' ;NUMERO 5 retlw B'11111010' ;NUMERO 6 retlw B'00001110' ;NUMERO 7 retlw B'11111110' ;NUMERO 8 retlw B'11011110' ;NUMERO 9 retlw B'11101110' ;LETRA A retlw B'11111000' ;LETRA B retlw B'01110010' ;LETRA C retlw B'10111100' ;LETRA D retlw B'11110010' ;LETRA E retlw B'11100010' ;LETRA F clrf Contador ;REINICIA EL CONTADOR retlw B'01111110' ;NUMERO 0 return
DELAY_1MS MOVLW .250 MOVWF CONT LOOP NOP DECFSZ CONT,F GOTO LOOP RETURN
DELAY_10MS MOVLW .10 MOVWF CONT2 LOOP2 CALL DELAY_1MS DECFSZ CONT2,F GOTO LOOP2 RETURN
DELAY_1S MOVLW .100 MOVWF CONT3 LOOP3 CALL DELAY_10ms DECFSZ CONT3,F GOTO LOOP3 RETURN
end
|
|
|
4
|
Programación / Programación C/C++ / Error al compilar, error de linker: Undefined reference to...
|
en: 26 Septiembre 2018, 18:13 pm
|
Al querer compilar en el main, me tira siguiente error: -undefined reference to "CrearTorneo" -undefined reference to AgregarNadador -undefined reference ... error: ld returned 1 exit status. Son codigos de un compañero que copie y pegue en un nuevo archivo mio, y a mi solo no me esta funcionando. alguna solucion? MAIN: #include <stdio.h> #include <stdlib.h> #include <string.h> #include "nadadores.h" #include "torneo.h"
int main() { torneo t = CrearTorneo(); AgregarNadador(t); MostrarNadadores(t); AgregarNadador(t); system("CLS"); MostrarNadadores(t); return 0; }
nadadores.h #ifndef NADADORES_H_INCLUDED #define NADADORES_H_INCLUDED
struct EstructuraNadadores; typedef struct EstructuraNadadores *nadador; nadador CrearNadador(); void MostrarNadador(nadador n);
#endif // NADADORES_H_INCLUDED
torneo.h #ifndef TORNEO_H_INCLUDED #define TORNEO_H_INCLUDED
struct EstructuraTorneo; typedef struct EstructuraTorneo *torneo; torneo CrearTorneo(); torneo AgregarNadador(torneo t); void MostrarNadadores(torneo t);
#endif // TORNEO_H_INCLUDED
nadadores.c #include <stdio.h> #include <stdlib.h> #include <string.h> #include "nadadores.h" #include "torneo.h"
struct EstructuraNadadores { char nombre[20]; char apellido[20]; int numeroDeAtleta; float peso; int ranking; int mejorTiempo20m; int mejorTiempo50m; };
nadador CrearNadador() { struct EstructuraNadadores*n = malloc(sizeof(struct EstructuraNadadores)); char a[20]; char b[20]; fflush(stdin); printf("Nombre: "); gets(a); strcpy(n->nombre,a); fflush(stdin); printf("Apellido: "); gets(b); strcpy(n->apellido,b); fflush(stdin); printf("peso: "); scanf("%f", &n->peso); fflush(stdin); printf("Numero de Atleta: "); scanf("%d", &n->numeroDeAtleta); fflush(stdin); printf("Ranking: "); scanf("%d", &n->ranking); fflush(stdin); printf("Mejor tiempo en 20 metros: "); scanf("%d", &n->mejorTiempo20m); fflush(stdin); printf("Mejor tiempo en 50 metros: "); scanf("%d", &n->mejorTiempo50m);
printf("\n\n");
return n; }
void MostrarNadador(nadador n) { printf("Nombre: %s\nApellido: %s\nNumero de atleta: %d\nPeso: %f\nRanking: %d\nMejor tiempo en 20 metros: %d\nMejor tiempo en 50 metros: %d\n", n->nombre, n->apellido, n->numeroDeAtleta, n->peso, n->ranking, n->mejorTiempo20m, n->mejorTiempo50m); }
torneo.c #include <stdio.h> #include <stdlib.h> #include <string.h> #include "nadadores.h" #include "torneo.h"
struct EstructuraNadadores { char nombre[20]; char apellido[20]; int numeroDeAtleta; float peso; int ranking; int mejorTiempo20m; int mejorTiempo50m; };
nadador CrearNadador() { struct EstructuraNadadores*n = malloc(sizeof(struct EstructuraNadadores)); char a[20]; char b[20]; fflush(stdin); printf("Nombre: "); gets(a); strcpy(n->nombre,a); fflush(stdin); printf("Apellido: "); gets(b); strcpy(n->apellido,b); fflush(stdin); printf("peso: "); scanf("%f", &n->peso); fflush(stdin); printf("Numero de Atleta: "); scanf("%d", &n->numeroDeAtleta); fflush(stdin); printf("Ranking: "); scanf("%d", &n->ranking); fflush(stdin); printf("Mejor tiempo en 20 metros: "); scanf("%d", &n->mejorTiempo20m); fflush(stdin); printf("Mejor tiempo en 50 metros: "); scanf("%d", &n->mejorTiempo50m);
printf("\n\n");
return n; }
void MostrarNadador(nadador n) { printf("Nombre: %s\nApellido: %s\nNumero de atleta: %d\nPeso: %f\nRanking: %d\nMejor tiempo en 20 metros: %d\nMejor tiempo en 50 metros: %d\n", n->nombre, n->apellido, n->numeroDeAtleta, n->peso, n->ranking, n->mejorTiempo20m, n->mejorTiempo50m); }
|
|
|
|
|
|
|