SHARE
TWEET

Untitled

a guest Sep 18th, 2019 100 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. typedef struct vetor_t{
  4.     int N;
  5.     int vec[200];
  6. }vetor;
  7.  
  8. void soma_vec(vetor *v1, vetor *v2, vetor *v3)
  9. {
  10.     for (int i = 0; i < v1->N; i++)
  11.     {
  12.         v3->vec[i] = v1->vec[i] + v2->vec[i];
  13.     }
  14.    
  15. }
  16.  
  17. int main(){
  18.  
  19.     vetor v1;
  20.     vetor v2;
  21.     vetor v3;
  22.  
  23.     v1.N = 3;
  24.     v1.vec[0]  = 3;
  25.     v1.vec[1]  = 4;
  26.     v1.vec[2]  = 5;
  27.    
  28.     v2.N = 3;
  29.     v2.vec[0]  = 3;
  30.     v2.vec[1]  = 4;
  31.     v2.vec[2]  = 5;
  32.    
  33.     v3.N = 3;
  34.    
  35.     soma_vec(&v1,&v2,&v3);
  36.  
  37.     for (int i = 0; i < v3.N; i++)
  38.     {
  39.         printf("%d ", v3.vec[i]);
  40.     }
  41.     printf("\n");
  42.  
  43.     return 0;
  44.  
  45. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top