Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <locale.h>
- #define TAM 5
- int main(){
- setlocale(LC_ALL,"Portuguese");
- int x[TAM], y[TAM], dif[TAM], c, c2, c3, n=0, uniao[TAM*2], aux=0;
- printf("Lendo o vetor X: n");
- for (c=0; c<TAM; c++){
- scanf("%d", &x[c]);
- }
- printf("nnLendo o vetor Y: n");
- for (c=0; c<TAM; c++){
- scanf("%d", &y[c]);
- }
- system("CLS");
- printf("Soma entre X e Y:n");
- for (c=0; c<TAM; c++){
- printf("%dn", x[c] + y[c]);
- }
- printf("nnProduto entre X e Y:n");
- for (c=0; c<TAM; c++){
- printf("%dn", x[c] * y[c]);
- }
- printf("nnDiferenca ente X e Y:n");
- for(c=0; c<TAM; c++){
- for(c2=0; c2<TAM; c2++){
- if(x[c] == y[c2])
- break;
- }
- if(c2==TAM){
- for(c3=0; c3<n; c3++){
- if(x[c] == dif[c])
- break;
- }
- if(c3 == n)
- dif[n++] = x[c];
- }
- }
- for (c=0; c<n; c++){
- printf("%dn", dif[c]);
- }
- printf("nnIntersecção entre X e Y:n");
- for (c=0; c<TAM; c++){
- for (c2=0; c2<TAM; c2++){
- if (x[c] == y[c2]){
- printf("%dn", x[c]);
- }
- }
- }
- printf("nnUnião entre X e Y:n");
- }
Add Comment
Please, Sign In to add comment