SHARE
TWEET

Untitled

a guest Sep 18th, 2019 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Questao 1
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5.  
  6. typedef struct vetor_t{
  7.     int n;
  8.     int vec[200];
  9.  
  10. }vetor;
  11.  
  12. vetor soma(vetor* v1,vetor* v2){
  13.     vetor v3;
  14.     for(int i = 0; i < v1->n;i++){
  15.         v3.vec[i] = v1->vec[i] + v2->vec[i];
  16.     }
  17.     printf("\n");
  18.     return v3;
  19. }
  20.  
  21. int main(){
  22.     vetor v1;
  23.     vetor v2;
  24.     vetor vr;
  25.     int num;
  26.  
  27.     printf("Tamanho N dos vetores: ");
  28.     scanf("%d",&num);
  29.     v1.n = num;
  30.     for(int i = 0;i < num;i++){
  31.         v1.vec[i] = rand() % 10;
  32.     }
  33.  
  34.     v2.n = num;
  35.     for(int i = 0;i < num;i++){
  36.         v2.vec[i] = rand() % 10;
  37.     }
  38.  
  39.     vr = soma(&v1,&v2);
  40.  
  41.     for(int i = 0; i < num; i ++){
  42.         vr.vec[i];
  43.         printf("%d | ",vr.vec[i]);
  44.     }
  45.     return 0;
  46. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top