Advertisement
Sam-Sampaio

Exemplo_simples

May 14th, 2019
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.46 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int soma(int *v1, size_t tam_v1, int *v2, size_t tam_v2, int *v3) {
  4.     if(tam_v1 != tam_v2)    
  5.        return 0;
  6.  
  7.     for(unsigned int i=0; i < tam_V1; i++)  
  8.           *v3++ = *v1++ + *v2++;
  9.      return 1;
  10. }
  11.  
  12. int main(void){
  13.  
  14.     int v1[5] = {1,2,3,4,5};
  15.     int v2[5] = {6,7,8,9,10};
  16.  
  17.     int v3[5];
  18.  
  19.     if(soma(v1,5,v2,5,v3) == 1) {
  20.         for(int i=0; i < 5; i++)
  21.             printf("%d\n", v3[i]);
  22.     }
  23.  
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement