Lil Wald Posted November 3, 2020 Share Posted November 3, 2020 Descriere problema: ma chinui sa gasesc rezolvare la aceasta problema, dar nu reusesc Poze / Video (optional): Cod (sursa pe baza caruia sa ajutam, daca e cazul): Alte precizări: 1 Link to comment Share on other sites More sharing options...
TLG George Posted November 3, 2020 Share Posted November 3, 2020 (edited) @Lil Wald iti urez succes cu domnul Varga Iti atasez rezolvarea mea de anul trecut, insa nu mai tin minte daca este corecta sau daca e aceeasi cerinta, dar cu siguranta te va ajuta sa iti faci o idee. #include <stdio.h> #include <stdlib.h> void f1(int v[], int na) { int n=0; for(int i=1;i<=na;i++) n=n|(1<<v[i]); printf("%d", n); } void f2(int A[], int B[], int na, int nb) { int k=1, C[61]; for(int i=1;i<=na;i++) { for(int j=1;j<=nb;j++) if(A[i]==B[j]) { C[k]=A[i]; k++; } } f1(C, k-1); } void f3(int A[], int B[], int na, int nb) { int k=1, C[61]; for(int i=1;i<=na;i++) { int ok=0; for(int j=1;j<=nb;j++) { if(A[i]==B[j]) ok++; } if(ok==0) { C[k]=A[i]; k++; } } f1(C, k-1); } int main() { int A[61], B[61],i,na,nb,k; scanf("%d", &na); for(i=1;i<=na;i++) { printf("A[i]= ", i); scanf("%d", &A[i]); } scanf("%d", &nb); for(i=1;i<=nb;i++) { printf("B[i]= ", i); scanf("%d", &B[i]); } printf("multimea A este transfrormata in numarul intreg: "); f1(A, na); printf("\n"); printf("intersectia celor doua multimi scrisa ca numar intreg este: "); f2(A, B, na, nb); printf("\n"); printf("diferenta celor doua multimi scrisa ca numar intreg este: "); f3(A, B, na, nb); return 0; } Edited November 3, 2020 by TLG Grizzly 2 Link to comment Share on other sites More sharing options...
Lil Wald Posted November 3, 2020 Author Share Posted November 3, 2020 47 minutes ago, TLG Grizzly said: @Lil Wald iti urez succes cu domnul Varga Iti atasez rezolvarea mea de anul trecut, insa nu mai tin minte daca este corecta sau daca e aceeasi cerinta, dar cu siguranta te va ajuta sa iti faci o idee. Reveal hidden contents #include <stdio.h> #include <stdlib.h> void f1(int v[], int na) { int n=0; for(int i=1;i<=na;i++) n=n|(1<<v[i]); printf("%d", n); } void f2(int A[], int B[], int na, int nb) { int k=1, C[61]; for(int i=1;i<=na;i++) { for(int j=1;j<=nb;j++) if(A[i]==B[j]) { C[k]=A[i]; k++; } } f1(C, k-1); } void f3(int A[], int B[], int na, int nb) { int k=1, C[61]; for(int i=1;i<=na;i++) { int ok=0; for(int j=1;j<=nb;j++) { if(A[i]==B[j]) ok++; } if(ok==0) { C[k]=A[i]; k++; } } f1(C, k-1); } int main() { int A[61], B[61],i,na,nb,k; scanf("%d", &na); for(i=1;i<=na;i++) { printf("A[i]= ", i); scanf("%d", &A[i]); } scanf("%d", &nb); for(i=1;i<=nb;i++) { printf("B[i]= ", i); scanf("%d", &B[i]); } printf("multimea A este transfrormata in numarul intreg: "); f1(A, na); printf("\n"); printf("intersectia celor doua multimi scrisa ca numar intreg este: "); f2(A, B, na, nb); printf("\n"); printf("diferenta celor doua multimi scrisa ca numar intreg este: "); f3(A, B, na, nb); return 0; } Mersi mult 1 Link to comment Share on other sites More sharing options...
CouldnoT Posted November 3, 2020 Share Posted November 3, 2020 @Lil Wald Your post isn't well readable, please try to make it better looking. I suggest you to give it a try, organize your problem to small sub-programs and work on each sub-program separated. That's what I usually do. Thus, If you failed to solve it, try to get the general idea from my colleagues approach and work on your own. Great thanks to my colleague for his help and to you for choosing this section. 1 Link to comment Share on other sites More sharing options...
TLG George Posted November 3, 2020 Share Posted November 3, 2020 Topic closed. Link to comment Share on other sites More sharing options...
Recommended Posts