Advertisement
edutedu

k secventa program dani BAC 2020

Oct 16th, 2020
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. ifstream in ("bac.txt");
  9. int k; in>>k;
  10. int lmax=0; int cnt=0, nrsecvente=1;
  11. int nr;
  12. while (in>>nr){
  13. if (nr%k==0){
  14. cnt++;
  15. }
  16. else{
  17. if (cnt==lmax && lmax!=0)
  18. nrsecvente++;
  19. if (cnt>lmax){
  20. lmax=cnt;
  21. nrsecvente=1;
  22. }
  23. cnt=0;
  24. }
  25. }
  26. if (cnt==lmax && lmax!=0)
  27. nrsecvente++;
  28. if (cnt>lmax){
  29. lmax=cnt;
  30. nrsecvente=1;
  31. }
  32.  
  33. cout<<lmax<<" "<<nrsecvente;
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement