Guest User

Untitled

a guest
Jul 18th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <locale.h>
  3. #define TAM 5
  4.  
  5.  
  6. int main(){
  7. setlocale(LC_ALL,"Portuguese");
  8.  
  9. int x[TAM], y[TAM], dif[TAM], c, c2, c3, n=0, uniao[TAM*2], aux=0;
  10.  
  11. printf("Lendo o vetor X: n");
  12. for (c=0; c<TAM; c++){
  13. scanf("%d", &x[c]);
  14. }
  15.  
  16. printf("nnLendo o vetor Y: n");
  17. for (c=0; c<TAM; c++){
  18. scanf("%d", &y[c]);
  19. }
  20.  
  21. system("CLS");
  22.  
  23. printf("Soma entre X e Y:n");
  24. for (c=0; c<TAM; c++){
  25. printf("%dn", x[c] + y[c]);
  26. }
  27.  
  28. printf("nnProduto entre X e Y:n");
  29. for (c=0; c<TAM; c++){
  30. printf("%dn", x[c] * y[c]);
  31. }
  32.  
  33. printf("nnDiferenca ente X e Y:n");
  34. for(c=0; c<TAM; c++){
  35. for(c2=0; c2<TAM; c2++){
  36. if(x[c] == y[c2])
  37. break;
  38. }
  39.  
  40. if(c2==TAM){
  41. for(c3=0; c3<n; c3++){
  42. if(x[c] == dif[c])
  43. break;
  44. }
  45.  
  46. if(c3 == n)
  47. dif[n++] = x[c];
  48. }
  49. }
  50.  
  51. for (c=0; c<n; c++){
  52. printf("%dn", dif[c]);
  53. }
  54.  
  55. printf("nnIntersecção entre X e Y:n");
  56. for (c=0; c<TAM; c++){
  57. for (c2=0; c2<TAM; c2++){
  58. if (x[c] == y[c2]){
  59. printf("%dn", x[c]);
  60. }
  61. }
  62. }
  63.  
  64. printf("nnUnião entre X e Y:n");
  65. }
Add Comment
Please, Sign In to add comment