Advertisement
Norbysweg

Untitled

Nov 11th, 2021
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int n,m,x[1001],a[501],b[501],j,db=0;
  8. bool f=1;
  9. ifstream fin("BAC.DAT");
  10. fin>>n>>m;
  11. for(int i=0;i<n;i++)
  12. fin>>x[i];
  13. for(int i=0;i<m;i++)
  14. {
  15. fin>>a[i]>>b[i];
  16. if(a[i]>b[i])
  17. {
  18. a[i]=a[i]+b[i];
  19. b[i]=a[i]-b[i];
  20. a[i]=a[i]-b[i];
  21. }
  22. }
  23. fin.close();
  24. for(int i=0;i<m;i++)
  25. {
  26. j=0;
  27. f=1;
  28. while(j<n&&f)
  29. {
  30. if(x[j]>=a[i] && x[j]<=b[i])
  31. j++;
  32. else
  33. f=0;
  34. }
  35. if(f)
  36. db++;
  37. }
  38. cout<<db;
  39. return 0;
  40. }
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement