메뉴 건너뛰기

Programing

Code Up

1525

관리자 2019.12.20 18:24 조회 수 : 9

C++

#include <cstdio>

#include <vector>

 

using namespace std;

vector <pair<int,int>> vec;

int map_[15][15],player_n,player[10];

int dr[4]={0,0,1,-1};

int dc[4]={1,-1,0,0};

int main()

{

    for(int i=0;i<10;i++){

        for(int j=0;j<10;j++){

            scanf("%d",&map_[i][j]);

            if(map_[i][j]>=1){

                vec.push_back({i,j});

            }

        }

    }

    for( auto &p: vec){

        int num=map_[p.first][p.second];

        map_[p.first][p.second]=-2;

        for(int i=0;i<4;i++){

            int r = p.first;

            int c = p.second;

            for(int j=0;j<num;j++){

                r += dr[i];

                c += dc[i];

                if(r<0||c<0||r>=10||c>=10||map_[r][c]==-1)

                    break;

 

                if(map_[r][c]!=0){

                    continue;

                }

                map_[r][c]=-2;

            }

        }

    }

    scanf("%d",&player_n);

    int a,b;

    for(int i=0;i<player_n;i++){

        scanf("%d %d",&a,&b);

        a--;

        b--;

        if(map_[a][b]==-2){

            player[i]=1;

        }else{

            map_[a][b]=i+1;

        }

    }

    for(int r=0;r<10;r++){

        for(int c=0;c<10;c++){

            printf("%d ",map_[r][c]);

        }

        printf("\n");

    }

    printf("Character Information\n");

    for(int i=0;i<player_n;i++){

            if(i!=0){

                printf("\n");

            }

        printf("player %d %s",i+1,(player[i]==1) ? "dead":"survive");

    }

    return 0;

}

번호 제목 글쓴이 날짜 조회 수
공지 안내사항 관리자 2019.12.02 175
172 3703 관리자 2019.12.20 8
171 3701 관리자 2019.12.20 9
170 3520 관리자 2019.12.20 8
169 3120 관리자 2019.12.20 8
168 3023 관리자 2020.04.06 60
167 3022 관리자 2020.04.06 51
166 3021 관리자 2020.04.06 63
165 3009 관리자 2019.12.20 8
164 3008 관리자 2019.12.20 6
163 3007 관리자 2019.12.20 7
162 3006 관리자 2019.12.20 14
161 2748 관리자 2019.12.20 9
160 2657 관리자 2019.12.20 21
159 2652 관리자 2019.12.20 7
158 2641 관리자 2019.12.20 7
157 2634 관리자 2019.12.20 6
156 1953 관리자 2019.12.20 7
155 1936 관리자 2019.12.20 7
154 1925 관리자 2019.12.20 7
» 1525 관리자 2019.12.20 9
152 1505 관리자 2019.12.20 7
151 1476 관리자 2019.12.20 3
150 1162 관리자 2019.12.20 7
149 1161 관리자 2019.12.20 7
148 1160 관리자 2019.12.20 7
147 1159 관리자 2019.12.20 5
146 1158 관리자 2019.12.20 5
145 1157 관리자 2019.12.20 10
144 1156 관리자 2019.12.20 7
143 1155 관리자 2019.12.20 5
위로