Advertisement
a53

p_e_n_t_a_g_o_n

a53
Sep 19th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #include <fstream>
  2. using namespace std;
  3. ifstream f("pentagon.in");
  4. ofstream g("pentagon.out");
  5. char c[201][201];
  6. short n,m,s[201];
  7.  
  8. void numara()
  9. {
  10. bool cod;
  11. short nr;
  12. for(short j=0;j<n;++j)
  13. {
  14. nr=0;
  15. cod=c[0][j]=='1';
  16. for(short i=0;i<m;++i)
  17. if(c[i][j]=='1')
  18. {
  19. if(!cod)
  20. cod=true,++s[nr],nr=0;
  21. }
  22. else
  23. {
  24. if(cod)
  25. nr=1,cod=false;
  26. else
  27. ++nr;
  28. }
  29. if(!cod)
  30. cod=true,++s[nr];
  31. }
  32. }
  33.  
  34. int main()
  35. {
  36. f>>m>>n;
  37. f.get();
  38. for(short i=0;i<m;++i)
  39. f>>c[i];
  40. f.close();
  41. numara();
  42. for(short k=1;k<=m;++k)
  43. if(s[k]!=0)
  44. g<<k<<' '<<s[k]<<'\n';
  45. g.close();
  46. return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement