Suma dos vectores
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 | {-Victor De la Rocha} {-Algoritmia@groups.msn.com} {-www.myalgorithm.com} uses crt;type vector=array [1..100] of integer; var arreglo1:vector; arreglo2:vector; long1,long2,cont,suma:integer; begin ClrScr; Write('Vector 1 (longitud): ');Readln(long1); write('Vector 2 (longitud): ');Readln(long2); writeln; suma:=0; writeln('Vector 1'); for cont:=1 to long1 do begin write('Valor ',cont,': ');Readln(arreglo1[cont]); suma:=arreglo1[cont]+suma; end; writeln; writeln('Vector 2'); for cont:=1 to long2 do begin write('Valor ',cont,': ');Readln(arreglo2[cont]); suma:=arreglo2[cont]+suma ; end; writeln; write('Suma ambos vectores: ',suma); ReadKey; end. |
Cantidad de valores vector 1: 27 Cantidad de valores vector 2: 11 Vector1[1]: 87 Vector1[2]: 46 Vector1[3]: -25 Vector1[4]: -32 Vector1[5]: 14 Vector1[6]: -48 Vector1[7]: 39 Vector1[8]: 51 Vector1[9]: 11 Vector1[10]: 13
Vector1[11]: -19
Vector1[12]: -5
Vector1[13]: 53
Vector1[14]: 74
Vector1[15]: 43
Vector1[16]: 58
Vector1[17]: 42
Vector1[18]: 54
Vector1[19]: 86
Vector1[20]: -27
Vector1[21]: -45
Vector1[22]: 100
Vector1[23]: 49
Vector1[24]: -2
Vector1[25]: -8
Vector1[26]: -20
Vector1[27]: 99
Vector2[1]: 16
Vector2[2]: -18
Vector2[3]: -7
Vector2[4]: 22
Vector2[5]: -16
Vector2[6]: -26
Vector2[7]: 57
Vector2[8]: -16
Vector2[9]: 86
Vector2[10]: 97
Vector2[11]: 17
suma: 900