Thread Rating:
• 0 Vote(s) - 0 Average
• 1
• 2
• 3
• 4
• 5
 Big Multiplication Limitless (Collection) lrcvs Junior Member Posts: 47 Threads: 16 Joined: Apr 2008 12-28-2009, 04:59 AM 'PROGRAM : MULTIPLICATION LIMITLESS VER #1 'LRCVS 01.01.2010 'THIS PROGRAM SIMPLY MAKES A MULTIPLICATION 'WITH ALL THE PARTIAL PRODUCTS. '............................................................ DECLARE SUB A.INICIO (A\$, B\$) DECLARE SUB B.STORE (CAD\$, N\$) DECLARE SUB C.PIZARRA () DECLARE SUB D.ENCABEZADOS (A\$, B\$) DECLARE SUB E.MULTIPLICACION (A\$, B\$) DECLARE SUB G.SUMA () DECLARE FUNCTION F.INVCAD\$ (CAD\$) CALL A.INICIO(A\$, B\$) CALL B.STORE(A\$, "A") CALL B.STORE(B\$, "B") CALL C.PIZARRA CALL D.ENCABEZADOS(A\$, B\$) CALL E.MULTIPLICACION(A\$, B\$) CALL G.SUMA SUB A.INICIO (A\$, B\$) CLS INPUT "NUMERO DE MUPLICACIONESÂ  "; S CLS A\$ = "" B\$ = "" FOR N = 1 TO S RANDOMIZE TIMER A\$ = A\$ + LTRIM\$(STR\$(INT(RND * 9))) NEXT N FOR N = 1 TO S RANDOMIZE TIMER B\$ = B\$ + LTRIM\$(STR\$(INT(RND * 9))) NEXT N END SUB SUB B.STORE (CAD\$, N\$) 'AQUI GUARDAMOS LOS DATOS EN UN FICHERO OPEN "O", #1, N\$ FOR M = LEN(CAD\$) TO 1 STEP -1 WRITE #1, MID\$(CAD\$, M, 1) NEXT M CLOSE (1) END SUB SUB C.PIZARRA 'INICIAMOS LA PIZZARA OPEN "A", #3, "R" WRITE #3, "" CLOSE (3) KILL "R" END SUB SUB D.ENCABEZADOS (A\$, B\$) 'AQUI ESCRIBIMOS LOS DATOS EN EL FICHERO FINAL 'VARIABLES 'LT :NUM,LONGITUD TOTAL DEL MULTIPLICANDO + MULTIPLICADOR 'L\$ :TEX, CADENA PATRON LT = LEN(A\$) + LEN(B\$) + 1 'ESCRIBIMOS EL MULTIPLICANDO L\$ = STRING\$(LT, " ") OPEN "A", #3, "R" MID\$(L\$, LT - LEN(A\$) + 1) = A\$ WRITE #3, L\$ CLOSE (3) 'ESCRIBIMOS EL MULTIPLICADOR L\$ = STRING\$(LT, " ") OPEN "A", #3, "R" MID\$(L\$, LT - LEN(B\$) - 1) = "X " + B\$ WRITE #3, L\$ CLOSE (3) END SUB SUB E.MULTIPLICACION (A\$, B\$) 'AQUI HACEMOS LA MULTIPLICACION 'VARIABLES 'LT : NUM, LONGITUD TOTAL DEL MULTIPLICANDO + MULTIPLICADOR 'RP : NUM, RESULTADO PARCIAL 'ACUM : NUM, ACUMULADOR DE LAS MULTIPLICACIONES 'LS : TEX, CADENA PATRON 'C\$ : TEX, CADENA DE TEXTO DEL RESULTADO PARCIAL 'D\$ : TEX, VALOR DE LAS UNIDADES 'E\$ : TEX, VALOR DE LO QUE NOS LLEVAMOS LT = LEN(A\$) + LEN(B\$) + 1 L\$ = STRING\$(LT, " ") C\$ = "" D\$ = "" E\$ = "" CT1 = 1 ACUM = 0 OPEN "I", #2, "B" WHILE EOF(2) <> -1 INPUT #2, B\$ OPEN "I", #1, "A" WHILE EOF(1) <> -1 INPUT #1, A\$ RP = (VAL(A\$) * VAL(B\$)) + ACUM C\$ = LTRIM\$(STR\$(RP)) IF EOF(1) <> -1 THEN D\$ = D\$ + RIGHT\$(C\$, 1) IF EOF(1) = -1 THEN D\$ = D\$ + F.INVCAD\$(C\$) E\$ = LEFT\$(C\$, LEN(C\$) - 1) ACUM = VAL(E\$) WEND CLOSE (1) MID\$(L\$, LT - CT1 - LEN(D\$) + 2) = F.INVCAD\$(D\$) OPEN "A", #3, "R" WRITE #3, L\$ CLOSE (3) L\$ = STRING\$(LT, " ") ACUM = 0 C\$ = "" D\$ = "" E\$ = "" CT1 = CT1 + 1 WEND CLOSE (2) END SUB FUNCTION F.INVCAD\$ (CAD\$) 'AQUI INVERTIMOS UNA CADENA DE TEXTO 'VARIABLES 'LCAD : NUM, LONGITUD CADENA ENTRANTE 'CADTEM\$ : TEX, ACUMULADOR CADENA TEMPORAL LCAD = LEN(CAD\$) CADTEM\$ = "" FOR CAD = LCAD TO 1 STEP -1 CADTEM\$ = CADTEM\$ + MID\$(CAD\$, CAD, 1) NEXT CAD F.INVCAD\$ = CADTEM\$ END FUNCTION SUB G.SUMA 'AQUI SUMAMOS LA MULTIPLICACION 'VARIABLES 'CF: NUM, CONTADOR DEL NUMERO DE FILAS 'AN: NUM, LONGITUD DEL REGISTRO 'ST: NUM, RESULTADO PARCIAL 'ACUS: NUM, ACUMULADOR DE LAS QUE NOS LLEVAMOS 'K: NUM, CONTADOR DE FILAS 'W\$: TEX, RESULTADO FINAL 'R\$: TEX, REGISTRO 'AQUI CALCULAMOS EL ANCHO DEL REGISTRO CF = 0 OPEN "I", #3, "R" WHILE EOF(3) <> -1 INPUT #3, R\$ CF = CF + 1 AN = LEN(R\$) WEND CF = CF - 2 CLOSE (3) W\$ = "" ST = 0 ACUS = 0 FOR P = 1 TO AN K = 0 OPEN "I", #3, "R" WHILE EOF(3) <> -1 INPUT #3, R\$ K = K + 1 IF K > 2 THEN ST = ST + VAL(MID\$(R\$, AN - P + 1, 1)) IF K > 2 THEN M\$ = LTRIM\$(STR\$(ST + ACUS)) WEND 'COLOR 10: LOCATE CF + 3, AN - P + 1: PRINT RIGHT\$(M\$, 1); : COLOR 7 W\$ = W\$ + RIGHT\$(M\$, 1) ACUS = VAL(LEFT\$(M\$, LEN(M\$) - 1)) CLOSE (3) ST = 0 NEXT P 'AQUI ESCRIBIMOS EL RESULTADO EN EL FICHERO OPEN "A", #3, "R" WRITE #3, " " + RIGHT\$(F.INVCAD(W\$), AN - 1) CLOSE (3) CLS PRINT "LA SOLUCION A ESTA MULTIPLICACION SE ENCUENTRA EN UN FICHERO DE TEXTO LLAMADO: R" END SUB 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'PROGRAM: FAST MULTIPLICATION. 'LRCVS 01.01.2010 'THIS PROGRAM SIMPLY MAKES A FAST MULTIPLICATION. 'HERE IS ONLY THE SOLUTION. '...................................................... CLS 'SOLUTION : 1676419739507419737831 A\$ = "123456789123456789" B\$ = "13579" C\$ = STRING\$(LEN(A\$)+LEN(B\$)," ") A = 0 H = (LEN(A\$)+LEN(B\$)) F = H FOR J = LEN(B\$) TO 1 STEP -1 FOR K = LEN(A\$) TO 1 STEP -1 R = (VAL(MID\$(B\$, J, 1)) * VAL(MID\$(A\$, K, 1))) + (A + VAL(MID\$(C\$, H, 1))) R\$ = LTRIM\$(STR\$®) U\$ = RIGHT\$(R\$, 1) IF LEN(R\$) >= 1 THEN A = VAL(LEFT\$(R\$, (LEN(R\$)-1))) IF K = 1 AND LEN(R\$) > 1 THEN H = H - 1 IF K = 1 THEN MID\$(C\$, H) = R\$ IF K > 1 THEN MID\$(C\$, H) = U\$ IF K > 1 THEN H = H -1 NEXT K A = 0 F = F - 1 H = F NEXT J PRINT C\$ END 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'PROGRAM: MULTIPLICATION LIMITLESS VER # 2 'LRCVS 01/01/2010 'THIS PROGRAM SIMPLY MAKES A MULTIPLICATION 'WITHOUT THE PARTIAL PRODUCTS. 'HERE SEE ONLY THE SOLUTION. 'HERE THERE IS NO LIMIT ON DIGITS. 'IS VERY FASTER AND AVOIDS MAKING REPEATED MULTIPLICATION. '............................................................... CLS PRINT "WAIT" T1 = TIMER NA = 1000 'NUMERO DE ELEMENTOS DEL MULTIPLICANDO, SIN LIMITE. NB = 100 'NUMERO DE ELEMENTOS DEL MULTIPLICADOR, SIN LIMITE. PRINT "MULTIPLICANDO = "; NA; " DIGITOS" PRINT "MULTIPLICADOR = "; NB; " DIGITOS" PRINT "NUMERO DE MULTIPLICACIONES = "; NA * NB PRINT "NUMERO DE DIGITOS EXACTOS = "; NA + NB PRINT "HORA INICIAL = "; TIME\$ '...................................................... 'AQUI ELIMINAMOS LOS POSIBLES CALCULOS ANTERIORES OPEN "X" + ".MLT" FOR BINARY AS #1 CLOSE (1) KILL "*.MLT" '...................................................... 'MULTIPLICANDO >>> A 'MULTIPLICADOR >>> B FOR N = 1 TO 2 IF N = 1 THEN F\$ = "A" + ".MLT": NN = NA IF N = 2 THEN F\$ = "B" + ".MLT": NN = NB Â  Â  OPEN F\$ FOR BINARY AS #1 Â  Â  Â  Â  FOR N2 = 1 TO NN Â  Â  Â  Â  RANDOMIZE TIMER Â  Â  Â  Â  X\$ = LTRIM\$(STR\$(INT(RND * 10))) Â  Â  Â  Â  SEEK #1, N2: PUT #1, N2, X\$ Â  Â  Â  Â  NEXT N2 Â  Â  SEEK #1, N2 Â  Â  CLOSE (1) NEXT N '..................................................... 'AQUI HACEMOS LAS MULTIPLICACIONES PARCIALES OPEN "A" + ".MLT" FOR BINARY AS #1 FOR K = 0 TO 9 NUM\$ = "": Z\$ = "": ACU = 0: GG = NA C\$ = LTRIM\$(STR\$(K)) Â  Â  OPEN C\$ + ".MLT" FOR BINARY AS #2 Â  Â  Â  Â  'OPEN "A" + ".MLT" FOR BINARY AS #1 Â  Â  Â  Â  Â  Â  FOR N = 1 TO NA Â  Â  Â  Â  Â  Â  SEEK #1, GG: GET #1, GG, X\$ Â  Â  Â  Â  Â  Â  NUM\$ = X\$ Â  Â  Â  Â  Â  Â  Z\$ = LTRIM\$(STR\$(ACU + (VAL(X\$) * VAL(C\$)))) Â  Â  Â  Â  Â  Â  L = LEN(Z\$) Â  Â  Â  Â  Â  Â  ACU = 0 Â  Â  Â  Â  Â  Â  IF L = 1 THEN NUM\$ = Z\$: PUT #2, N, NUM\$ Â  Â  Â  Â  Â  Â  IF L > 1 THEN ACU = VAL(LEFT\$(Z\$, LEN(Z\$) - 1)): NUM\$ = RIGHT\$(Z\$, 1): PUT #2, N, NUM\$ Â  Â  Â  Â  Â  Â  SEEK #2, N: PUT #2, N, NUM\$ Â  Â  Â  Â  Â  Â  GG = GG - 1 Â  Â  Â  Â  Â  Â  NEXT N Â  Â  Â  Â  IF L > 1 THEN ACU = VAL(LEFT\$(Z\$, LEN(Z\$) - 1)): NUM\$ = LTRIM\$(STR\$(ACU)): XX\$ = XX\$ + NUM\$: PUT #2, N, NUM\$ Â  Â  Â  Â  'CLOSE (1) Â  Â  CLOSE (2) NEXT K CLOSE (1) '...................................................... 'AQUI CREAMOS EL RESULTADO FINAL DE LA MULTIPLICACION EN: "D" ACU = 0 LT5 = 1 LT6 = LT5 'AQUI BUSCAMOS LOS ELEMENTOS DE B OPEN "B" + ".MLT" FOR BINARY AS #1 Â  Â  OPEN "D" + ".MLT" FOR BINARY AS #3 Â  Â  Â  Â  FOR JB = NB TO 1 STEP -1 Â  Â  Â  Â  SEEK #1, JB Â  Â  Â  Â  GET #1, JB, X\$ Â  Â  Â  Â  Â  Â  OPEN X\$ + ".MLT" FOR BINARY AS #2: LF = LOF(2): CLOSE (2) Â  Â  Â  Â  Â  Â  OPEN X\$ + ".MLT" FOR BINARY AS #2 Â  Â  Â  Â  Â  Â  Â  Â  FOR KB = 1 TO LF Â  Â  Â  Â  Â  Â  Â  Â  SEEK #2, KB Â  Â  Â  Â  Â  Â  Â  Â  GET #2, , NUM\$ Â  Â  Â  Â  Â  Â  Â  Â  SEEK #3, LT5 Â  Â  Â  Â  Â  Â  Â  Â  GET #3, LT5, PR\$ Â  Â  Â  Â  Â  Â  Â  Â  T\$ = "" Â  Â  Â  Â  Â  Â  Â  Â  T\$ = LTRIM\$(STR\$(ACU + VAL(NUM\$) + VAL(PR\$))) Â  Â  Â  Â  Â  Â  Â  Â  PR\$ = RIGHT\$(T\$, 1) Â  Â  Â  Â  Â  Â  Â  Â  ACU = 0 Â  Â  Â  Â  Â  Â  Â  Â  IF LEN(T\$) > 1 THEN ACU = LEFT\$(T\$, LEN(T\$) - 1) Â  Â  Â  Â  Â  Â  Â  Â  SEEK #3, LT5: PUT #3, LT5, PR\$ Â  Â  Â  Â  Â  Â  Â  Â  LT5 = LT5 + 1 Â  Â  Â  Â  Â  Â  Â  Â  NEXT KB Â  Â  Â  Â  Â  Â  Â  Â  IF ACU <> 0 THEN PR\$ = LTRIM\$(STR\$(ACU)): PUT #3, LT5, PR\$ Â  Â  Â  Â  Â  Â  CLOSE (2) Â  Â  Â  Â  LT6 = LT6 + 1 Â  Â  Â  Â  LT5 = LT6 Â  Â  Â  Â  ACU = 0 Â  Â  Â  Â  NEXT JB Â  Â  CLOSE (3) CLOSE (1) OPEN "D" + ".MLT" FOR BINARY AS #3: LD = LOF(3): CLOSE (3) 'AQUI INVERTIMOS EL RESULTADO FINAL ER = 1 OPEN "D" + ".MLT" FOR BINARY AS #3 Â  Â  OPEN "R" + ".MLT" FOR BINARY AS #4 Â  Â  Â  Â  FOR N = LD TO 1 STEP -1 Â  Â  Â  Â  SEEK #3, N: GET #3, N, PR\$ Â  Â  Â  Â  SEEK #4, ER: PUT #4, ER, PR\$ Â  Â  Â  Â  ER = ER + 1 Â  Â  Â  Â  NEXT N Â  Â  CLOSE (4) CLOSE (3) 'AQUI ELIMINAMOS LOS PRODUCTOS PARCIALES KILL "D.MLT" FOR N = 0 TO 9 C\$ = LTRIM\$(STR\$(N)) KILL C\$ + ".MLT" NEXT N T2 = TIMER PRINT "END" PRINT "HORA FINAL = "; TIME\$ PRINT "DIFERENCIA = "; T2 - T1; "SEGUNDOS" PRINT "SOLUTION IN THE FILE: R.MLT " 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX IN THIS DIRECTION WE CAN SEE THE PHOTOGRAPH OF THE FIRST MULTIPLICATION THAT DID. HTTP://LH5.GGPHT.COM/_QM8LM2MCLBE/SF3X6C...CATION.JPG 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Thancks all Friends !!!! BigBadKing Junior Member Posts: 3 Threads: 1 Joined: Oct 2009 12-28-2009, 08:46 PM Nice work! lrcvs Junior Member Posts: 47 Threads: 16 Joined: Apr 2008 12-28-2009, 11:21 PM Thancks !!! Regards lrcvs lrcvs Junior Member Posts: 47 Threads: 16 Joined: Apr 2008 12-29-2009, 03:42 AM (This post was last modified: 12-29-2009, 03:20 PM by wildcard.) Address of the image cache of the Post: Big Multiplication ... Parte 1 http://74.125.77.132/search?q=cache:t9xf...clnk&gl=se Parte 2 http://209.85.229.132/search?q=cache:Whu...clnk&gl=es The direction of the photo does not work. Writing on Google image: Big multiplication It is the first Regards lrcvs lrcvs Junior Member Posts: 47 Threads: 16 Joined: Apr 2008 01-05-2010, 03:48 AM Attachment file format "*. ZIP" of the cached copy of the original file. They are all friends who helped create this "short" multiplication. Thank you all. lrcvs lrcvs Junior Member Posts: 47 Threads: 16 Joined: Apr 2008 01-15-2010, 06:43 PM 'Program multiplication simple 'lrcvs '(MU) Spain '13 Jan 2010 'This program is based on: a * b = cÂ  >>>Â  a = c / b CLS a\$ = "9876543298789" b\$ = "2468013" la = LEN(a\$) + LEN(b\$) c\$ = STRING\$(la, "0") FOR r = 1 TO la Â  Â  FOR s = 0 TO 9 Â  Â  MID\$(c\$, r) = LTRIM\$(STR\$(s)) Â  Â  v\$ = LTRIM\$(STR\$(VAL(c\$) / VAL(b\$))) Â  Â  IF v\$ = a\$ THEN PRINT "Prog = "; VAL(c\$): PRINT : PRINT "Comp = "; VAL(a\$) * VAL(b\$): END Â  Â  IF VAL(a\$) > VAL(v\$) THEN MID\$(c\$, r) = LTRIM\$(STR\$(s)) Â  Â  IF VAL(a\$) < VAL(v\$) THEN MID\$(c\$, r) = LTRIM\$(STR\$(s - 1)): EXIT FOR Â  Â  NEXT s NEXT r SLEEP END « Next Oldest | Next Newest »

Forum Jump:

Users browsing this thread: 1 Guest(s)