Pascal/Turbo Pascal - como sumar dos numeros muy grandes

 
Vista:
sin imagen de perfil

como sumar dos numeros muy grandes

Publicado por luis (2 intervenciones) el 26/12/2013 18:02:40
¿como puedo hacer la suma de dos numeros enteros que tengan entre 10 y 100 digitos?
como por ejemplo 59874563214589625789625 + 25698745236985452369878526589652?
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

como sumar dos numeros muy grandes

Publicado por ramon (2158 intervenciones) el 28/12/2013 19:54:35
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
{Esto servirá}
 program numerosuma;
  uses
    crt;
  type
    numeros = array[1..100] of integer;
 
  var
    numero : array[1..2] of numeros;
    result : array[1..110] of integer;
    m, p, ii, cont, da : integer;
 
  procedure entradanumeros(var sum1, sum2 : numeros);
  var
    tec : char;
  begin
     clrscr;
     cont := 1;
     gotoxy(3,1);write('Entre sumando : ');
     repeat
         tec := readkey;
         if tec in[#48..#57] then
         begin
            numero[1][cont] := ord(tec) - 48;
            gotoxy(18 + cont,1);write(tec);
            cont := cont + 1;
         end;
         if tec = #8 then
         begin
            cont := cont - 1;
            numero[1][cont] := 0;
            gotoxy(18 + cont,1);write(' ');
         end;
     until tec = #13;
     da := 1;
     gotoxy(3,2);write('Entre sumador : ');
     repeat
         tec := readkey;
         if tec in[#48..#57] then
         begin
            numero[2][da] := ord(tec) - 48;
            gotoxy(18 + da,2);write(tec);
            da := da + 1;
         end;
         if tec = #8 then
         begin
            da := da - 1;
            numero[2][da] := 0;
            gotoxy(18 + da,2);write(' ');
         end;
     until tec = #13;
  end;
 
  procedure suma(en1, en2 : numeros);
  var
    d, i : integer;
    res, te : integer;
  begin
     i := 1;
     for d := 1 to cont - 1 do
     begin
      gotoxy(30 + i,3);write(numero[1][d]);
      i := i + 1;
     end;
      i := 1;
      for d := 1 to da - 1 do
      begin
      gotoxy((30 + ((cont - 1) - (da - 1))) + i,4);write(numero[2][d]);
      i := i + 1;
      end;
      for i := 1 to cont do
      begin
         gotoxy(30 + i,5);write('-');
      end;
       gotoxy(28,4);write('+');
      d := cont - 1;
      res := 0;
      p := da - 1;
      m := 1;
     repeat
      i := (numero[1][d] + numero[2][p]) + res;
      res := 0;
       te := i mod 10;
       i := i div 10;
       res := i;
       result[m] := te;
       m := m + 1;
       p := p - 1;
      d := d - 1;
    until d < 1;
    if res > 0 then
    begin
    result[m] := res;
    m := m + 1;
    end;
  end;
 
 
  begin
      entradanumeros(numero[1],numero[2]);
      clrscr;
      suma(numero[1],numero[2]);
      ii := 1;
      for da := 1 to m - 1 do
      begin
         gotoxy(30 + ii,6);write(result[m - da]);
         ii := ii + 1;
      end;
      readkey;
  end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
2
Comentar
sin imagen de perfil

como sumar dos numeros muy grandes

Publicado por luis (2 intervenciones) el 29/12/2013 18:57:46
Increible, muchas gracias
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar