Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <cmath>
- #include <algorithm>
- using namespace std;
- #define MAX 101
- int map[MAX][MAX]={};
- int minim[MAX][MAX];
- int check[MAX][MAX];
- int pollutedx,pollutedy;
- double velocity,velocitywater;
- int tt;
- int sizex,sizey;
- double dist(int x1, int y1, int x2, int y2) {
- return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
- }
- void showmap()
- {
- int i,j;
- printf("\n\n\n\n");
- for(i=0;i<sizex;i++){
- for(j=0;j<sizey;j++){
- printf("%d ",map[i][j]);
- }
- printf("\n");
- }
- printf("TIME IS %d\n",tt);
- system("pause");
- }
- void pollutingfunction()
- {
- int i,j,k,m,l=tt*velocitywater;
- //오염되는 과정
- for(i=0;i<sizex;i++){
- for(j=0;j<sizey;j++){
- for(k=pollutedx;k<pollutedx+l;k++){
- if((dist(i, j, k, pollutedy)<(velocity*(k-pollutedx)/velocitywater))&&!map[i][j]){
- check[i][j]=tt;
- map[i][j]=map[k][pollutedy]-tt/2;
- }
- }
- }
- }
- //정화되는 과정
- }
- int main()
- {
- int i,j;
- scanf("%d %d",&sizex,&sizey);
- scanf("%d %d",&pollutedx,&pollutedy);
- scanf("%lf %lf",&velocity,&velocitywater);
- for(i=0;i<sizex;i++){
- for(j=0;j<sizey;j++){
- scanf("%d",&map[i][j]);
- }
- }
- for(;;) {
- pollutingfunction();
- showmap();
- tt++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement