Advertisement
shakh101

Untitled

Nov 14th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. int main()
  2. {
  3. int num, num2; // the size of arrays
  4. cout << "Enter first value: ";
  5. cin >> num;
  6.  
  7.  
  8. int *A = new int[num];
  9. int *B = new int[num2];
  10. int *C = new int[num];
  11. int count = 0;
  12. for (int i=0; i< num ; i++){
  13. cin >> A[i];
  14. }
  15.  
  16. cout << "Enter second value: ";
  17. cin >> num2;
  18.  
  19. for (int j = 0; j<num2; j++){
  20. cin >> B[j];
  21. }
  22.  
  23. for (int i=0; i< num ; i++){
  24. int counter = 0;
  25.  
  26. for(int j = 0; j< num2; j++){
  27. if(B[j] == A[i]){
  28. count ++;
  29. }
  30. }
  31. if(count != 1){
  32. for (int g = 2; g<= count; g++) {
  33. if (count % g == 0) {
  34. counter++;
  35. }
  36. }
  37. if (counter == 1){
  38. C[i] = A[i];
  39. count = 0;
  40. }
  41. }
  42. }
  43.  
  44. for (int i=0; i< num ; i++){
  45. if(C[i] != 0){
  46. cout << C[i];
  47. }
  48. }
  49.  
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement