Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- ifstream f("pentagon.in");
- ofstream g("pentagon.out");
- char c[201][201];
- short n,m,s[201];
- void numara()
- {
- bool cod;
- short nr;
- for(short j=0;j<n;++j)
- {
- nr=0;
- cod=c[0][j]=='1';
- for(short i=0;i<m;++i)
- if(c[i][j]=='1')
- {
- if(!cod)
- cod=true,++s[nr],nr=0;
- }
- else
- {
- if(cod)
- nr=1,cod=false;
- else
- ++nr;
- }
- if(!cod)
- cod=true,++s[nr];
- }
- }
- int main()
- {
- f>>m>>n;
- f.get();
- for(short i=0;i<m;++i)
- f>>c[i];
- f.close();
- numara();
- for(short k=1;k<=m;++k)
- if(s[k]!=0)
- g<<k<<' '<<s[k]<<'\n';
- g.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement