More actions
imported>Unknown No edit summary |
(Repair batch-0003 pages from live compare) |
||
| Line 9: | Line 9: | ||
int length; | int length; | ||
int walk | int walk[100][100]; | ||
int i, j; | int i, j; | ||
int x , y; | int x , y; | ||
| Line 19: | Line 19: | ||
for (i = 0; i < length; i++){ | for (i = 0; i < length; i++){ | ||
for (j = 0; j < length; j++){ | for (j = 0; j < length; j++){ | ||
walk | walk[i][j] = 0; | ||
} // 초기화 | } // 초기화 | ||
} | } | ||
| Line 25: | Line 25: | ||
fin >> y; | fin >> y; | ||
walk | walk[x][y] = 0; | ||
while (!fin.eof()){ | while (!fin.eof()){ | ||
int directer = direct - 48; | int directer = direct - 48; | ||
| Line 67: | Line 67: | ||
if (y < 0) y += length; | if (y < 0) y += length; | ||
if (y == length) y -= length; | if (y == length) y -= length; | ||
walk | walk[y][x]++; | ||
direct = fin.get(); | direct = fin.get(); | ||
| Line 75: | Line 75: | ||
for (i = 0; i < length; i++){ | for (i = 0; i < length; i++){ | ||
for (j = 0; j < length; j++){ | for (j = 0; j < length; j++){ | ||
cout << walk | cout << walk[i][j] << " "; | ||
} | } | ||
cout << endl; | cout << endl; | ||
| Line 83: | Line 83: | ||
return 0; | return 0; | ||
} | } | ||
Latest revision as of 00:29, 27 March 2026
ScheduledWalk/권정욱
#include <iostream>
#include <fstream>
using namespace std;
int main(){
ifstream fin("input.txt");
ofstream fout("output.txt");
int length;
int walk[100][100];
int i, j;
int x , y;
char direct;
int temp;
fin >> length;
for (i = 0; i < length; i++){
for (j = 0; j < length; j++){
walk[i][j] = 0;
} // 초기화
}
fin >> x;
fin >> y;
walk[x][y] = 0;
while (!fin.eof()){
int directer = direct - 48;
if (direct == ' ' || direct =='\n') {
direct = fin.get();
continue;
}
if (direct == '9') break;
switch (directer){
case 1 :
x += 1;
y -= 1;
break;
case 2 :
x +=1;
break;
case 3 :
x += 1;
y += 1;
break;
case 4 :
y += 1;
break;
case 5 :
x -= 1;
y += 1;
break;
case 6 :
x -= 1;
break;
case 7 :
x -= 1;
y -= 1;
break;
case 0 :
y -= 1;
break;
}
if (x < 0) x += length;
if (x == length) x -= length;
if (y < 0) y += length;
if (y == length) y -= length;
walk[y][x]++;
direct = fin.get();
}
cout << endl;
for (i = 0; i < length; i++){
for (j = 0; j < length; j++){
cout << walk[i][j] << " ";
}
cout << endl;
}
return 0;
}