SHARE
TWEET

Untitled

a guest Dec 16th, 2018 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <cstdio>
  2. #include <cmath>
  3. #include <algorithm>
  4. using namespace std;
  5. #define MAX 101
  6. int map[MAX][MAX]={};
  7. int minim[MAX][MAX];
  8. int check[MAX][MAX];
  9. int pollutedx,pollutedy;
  10. double velocity,velocitywater;
  11. int tt;
  12. int sizex,sizey;
  13.  
  14. double dist(int x1, int y1, int x2, int y2) {
  15.     return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
  16. }
  17.  
  18. void showmap()
  19. {
  20.     int i,j;
  21.     printf("\n\n\n\n");
  22.     for(i=0;i<sizex;i++){
  23.         for(j=0;j<sizey;j++){
  24.             printf("%d ",map[i][j]);
  25.         }
  26.         printf("\n");
  27.     }
  28.     printf("TIME IS %d\n",tt);
  29.     system("pause");
  30. }
  31. void pollutingfunction()
  32. {
  33.     int i,j,k,m,l=tt*velocitywater;
  34.     //오염되는 과정
  35.     for(i=0;i<sizex;i++){
  36.         for(j=0;j<sizey;j++){
  37.             for(k=pollutedx;k<pollutedx+l;k++){
  38.                 if((dist(i, j, k, pollutedy)<(velocity*(k-pollutedx)/velocitywater))&&!map[i][j]){
  39.                     check[i][j]=tt;
  40.                     map[i][j]=map[k][pollutedy]-tt/2;
  41.                 }
  42.             }
  43.         }
  44.     }
  45.     //정화되는 과정
  46.    
  47. }
  48. int main()
  49. {
  50.     int i,j;
  51.     scanf("%d %d",&sizex,&sizey);
  52.     scanf("%d %d",&pollutedx,&pollutedy);
  53.     scanf("%lf %lf",&velocity,&velocitywater);
  54.     for(i=0;i<sizex;i++){
  55.         for(j=0;j<sizey;j++){
  56.             scanf("%d",&map[i][j]);
  57.         }
  58.     }
  59.     for(;;) {
  60.         pollutingfunction();
  61.         showmap();
  62.         tt++;
  63.     }
  64. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top