Nombre: Suma de vectores
Descripción:
Suma de dos arreglos con cuadros por funcion
URL: http://www.mygnet.net/codigos/cplusplus/matricesyvectores/suma_de_vectores.2808
Código Fuente:
#include <conio.h>
#include <stdio.h>
#include <iostream.h>
void fCuadro (int x1,int y1,int x2, int y2);
void main (){
fCuadro (5,8,10,14);
fCuadro (17,8,22,14);
fCuadro (29,8,34,14);
int arreglo1[3];
int arreglo2[3];
int suma[3];
gotoxy(5,3);cout<<"Suma de dos arreglos"<<endl<<endl;
gotoxy(13,9);cout<<"+";
gotoxy(23,9);cout<<"=";
gotoxy(5,7);cout<<"Arreglo 1"<<endl;
for (int h=0;h<3;h++){
gotoxy(8,h+10);
cin>>arreglo1[h];
}
gotoxy(17,7);cout<<"Arreglo 2"<<endl;
for (int h=0;h<3;h++){
gotoxy(20,h+10);
cin>>arreglo2[h];
}
for (int h=0;h<3;h++){
suma[h]=arreglo1[h]+arreglo2[h];
}
gotoxy(29,7);cout<<"Resultado"<<"n";
for (int x=0;x<3;x++){
gotoxy(32,x+10);
cout<<suma[x];
}
getch();
}
void fCuadro (int x1,int y1,int x2, int y2){
int x,y;
gotoxy (x1,y1);
for (x=x1; x<=x2;x++){
if (x==x1)
printf ("%c",218);
else if (x<x2)
printf ("%c",196);
if (x==x2)
printf ("%c",191);
}
for(y=y1+1;y<=y2;y++){
gotoxy (x1,y);
printf ("%c",179);
for(x=x1;x<=x2-2;x++)
printf ("%c",255);
printf ("%c",179);
}
gotoxy (x1,y2);
for (x=x1; x<=x2;x++){
if (x==x1)
printf ("%c",192);
else if (x<x2)
printf ("%c",196);
if (x==x2)
printf ("%c",217);
}
}