Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. void longestcharnotinset(int*, int*, int, int);
  6.  
  7. int main() {
  8.  
  9. cout << " Enter size of set : ";
  10. int N;
  11. cin >> N;
  12. int* set = new int[N];
  13. for (int i = 0; i < N; i++) {
  14. cin >> set[i];
  15. }
  16.  
  17. int M;
  18. cout << "How many numbers do you want to check for? : ";
  19. cin >> M;
  20. cout << "Enter " << M << " numbers from the set : \n";
  21. int* subset = new int[M];
  22.  
  23. for (int i = 0; i < M; i++) {
  24. cin >> subset[i];
  25. }
  26.  
  27. longestcharnotinset(set, subset,N,M);
  28.  
  29. cout << endl;
  30.  
  31.  
  32. return 0;
  33. }
  34.  
  35. void longestcharnotinset(int* set, int* subset, int N, int M)
  36. {
  37. int* longestnum = nullptr;
  38. int cnt = 0, cntcpy = 0;
  39. int firstnum;
  40. int lastnum;
  41.  
  42. for (int i = 0; i < 10; i++) {
  43. for (int j = i; j < M; j++) {
  44. if (set[i] == subset[j]) cnt++;
  45. if (cntcpy < cnt) cntcpy = cnt;
  46. }
  47. }
  48.  
  49. std::cout << "The highest cound of elements in a row in the set is " << cntcpy << std::endl;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement