Advertisement
a53

Zoom_Poza

a53
Nov 22nd, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int c,n,m,z;
  8. ifstream f("zoom_poza.in");
  9. f>>c>>n>>m>>z;
  10. ofstream g("zoom_poza.out");
  11. if(c==1)
  12. {
  13. int N=n*z,M=m*z;
  14. int x,a[N+1][M+1];
  15. for(int i=0;i<N;i+=z)
  16. for(int j=0;j<M;j+=z)
  17. {
  18. f>>x;
  19. for(int p=i;p<i+z;++p)
  20. for(int q=j;q<j+z;++q)
  21. a[p][q]=x;
  22. }
  23. for(int i=0;i<N;g<<'\n',++i)
  24. for(int j=0;j<M;++j)
  25. g<<a[i][j]<<' ';
  26. }
  27. else
  28. {
  29. int a[n+1][m+1];
  30. for(int i=0;i<n;++i)
  31. for(int j=0;j<m;++j)
  32. f>>a[i][j];
  33. int k,x,y;
  34. f>>k;
  35. while(k--)
  36. {
  37. f>>x>>y;
  38. --x;--y;
  39. if(x<z)
  40. x=0;
  41. else
  42. if(x>n)
  43. x/=z;
  44. if(y<z)
  45. y=0;
  46. else
  47. if(y>m)
  48. y/=z;
  49. g<<a[x][y]<<' ';
  50. }
  51. g<<'\n';
  52. }
  53. return 0;
  54. }
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement