Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Questao 1
- #include <stdio.h>
- #include <string.h>
- typedef struct vetor_t{
- int n;
- int vec[200];
- }vetor;
- vetor soma(vetor* v1,vetor* v2){
- vetor v3;
- for(int i = 0; i < v1->n;i++){
- v3.vec[i] = v1->vec[i] + v2->vec[i];
- }
- printf("\n");
- return v3;
- }
- int main(){
- vetor v1;
- vetor v2;
- vetor vr;
- int num;
- printf("Tamanho N dos vetores: ");
- scanf("%d",&num);
- v1.n = num;
- for(int i = 0;i < num;i++){
- v1.vec[i] = rand() % 10;
- }
- v2.n = num;
- for(int i = 0;i < num;i++){
- v2.vec[i] = rand() % 10;
- }
- vr = soma(&v1,&v2);
- for(int i = 0; i < num; i ++){
- vr.vec[i];
- printf("%d | ",vr.vec[i]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement