Advertisement
a53

Foto1

a53
Mar 11th, 2020
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #include <fstream>
  2. #include <iostream>
  3. using namespace std;
  4. ifstream f("foto.in");
  5. ofstream g("foto.out");
  6. int T[102][102];
  7. int main()
  8. {
  9. int C,N,M;
  10. f>>C>>N>>M;
  11.  
  12. if(C==1)
  13. {
  14. int x,P=0,i,j,p=0;
  15. for(i=1;i<=N;i++)
  16. { p=0;
  17. for(j=1;j<=M;j++)
  18. { f>>x;
  19. if(x==0)p++;
  20. else
  21. {P=max(p,P); p=0;}
  22. }
  23. P=max(P,p);
  24. }
  25. g<<P<<endl;
  26. }
  27. else
  28. {
  29. int H=0,F=0,i,j,h,r,c;
  30. for(r=1;r<=N;r++)
  31. for(c=1;c<=M;c++)
  32. f>>T[r][c];
  33. for(r=1; r<=N; r++)
  34. for(c=1; c<=M; c++)
  35. if(T[r][c]==1)
  36. { F++;
  37. i=r; j=c; h=0;
  38. while(T[i][j]==1)
  39. { h++;
  40. T[i][j]=0;
  41. if(T[i+1][j]==1)i++;
  42. else
  43. if(T[i+1][j-1]==1){i++;j--;}
  44. else
  45. if(T[i+1][j+1]==1){i++; j++;}
  46. }
  47. H=max(h,H);
  48. }
  49. g<<F<<" "<<H<<endl;
  50. }
  51. return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement