Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main()
- {
- ifstream in ("bac.txt");
- int k; in>>k;
- int lmax=0; int cnt=0, nrsecvente=1;
- int nr;
- while (in>>nr){
- if (nr%k==0){
- cnt++;
- }
- else{
- if (cnt==lmax && lmax!=0)
- nrsecvente++;
- if (cnt>lmax){
- lmax=cnt;
- nrsecvente=1;
- }
- cnt=0;
- }
- }
- if (cnt==lmax && lmax!=0)
- nrsecvente++;
- if (cnt>lmax){
- lmax=cnt;
- nrsecvente=1;
- }
- cout<<lmax<<" "<<nrsecvente;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement