Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Programa que suma dos vectores
- #include<stdio.h>
- class Vector
- {
- int c[10];
- int e;
- public:
- void inicia (void);
- void pon_dato(int i);
- void suma(Vector x, Vector y );
- void Visualizar(void);
- } ;
- Vector r;
- void Vector::inicia(void)
- {
- e=0;
- }
- void Vector::pon_dato(int i)
- {
- c[e++]=i;
- }
- void Vector::Visualizar(void)
- {
- int j;
- for(j=0;j<e;j++)
- printf("%d",c[j]);
- }
- void Vector::suma(Vector x, Vector y)
- {
- int j;
- if (x.e != y.e)
- printf( "No se pueden sumar los vectores");
- else
- for(j=0;j<x.e;j++)
- r.c[j] = x.c[j]+y.c[j];
- r.e=x.e;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement