jueves, 26 de junio de 2008

SUMA DE DOS VECTORES

CODIGO:

#include
class vectores
{
public:
int vr[2];
int v1[2], v2[2];
int x, y;
int sumar;
public:
void imprime()
{
gotoxy(5,1);
cout<<"Vector 1";
gotoxy(25,1);
cout<<"Vector 2";
gotoxy(45,1);
cout<<"Resultado";
gotoxy(20,7);
cout<<"+";
gotoxy(40,7);
cout<<"=";
}
void capturav1()
{
x=10;
y=4;
for(int i=0; i<2; i++)
{
gotoxy(x,y);
cin>>v1[i];
y=y+10;
}
}
void capturav2()
{
x=30;
y=4;
for(int i=0; i<2; i++)
{
gotoxy(x,y);
cin>>v2[i];
y=y+10;
}
}
void suma()
{
x=50;
y=4;
for(int i=0; i<2; i++)
{
sumar=0;
gotoxy(x,y);
sumar=v1[i]+v2[i];
cout< y=y+10;
}
}
};
void main()
{
clrscr();
vectores v;
v.imprime();
v.capturav1();
v.capturav2();
v.suma();
getch();
}