pyc9163blog.files.wordpress.com · Web viewC언어 집중 프로그램 The Love조 팀...
Transcript of pyc9163blog.files.wordpress.com · Web viewC언어 집중 프로그램 The Love조 팀...
C The Love
Mindstorm EV3 Magic Sqaure solver
(629 ~ 7 23)
2010251004
2010251005
2010251022
2010251037
2011251133
2012251169
Mindstorm( ) 2, 1, 1, 1, 1 , 2, , .
Bricx cc, VIsual Studio c#, Dev ev3, Robot C Linux Robot C . .
Robot C .
: moveMotorTarget (,, );
: waitUntilMotorStop();
: playSound(soundBeepBeep);
: sleep(); , wait1Msec(); // (1000=1)
: clearDebugStream();
: writeDebugStream();
: getColorReflected();
: stopAlltasks();
: DevuggerWindows()
(Thinning) .
int thinning( )
{
int count_step_1 = 0;
int count_step_2 = 0;
int p1, p2;
///////////////////
int i, j;
int a[8];
int y[h][w];
for (int n = 0; n < 8; n++) a[n] = 0;
//////////////////////////////////////////////////////
int cont = 1;
while (cont) {
cont = 0;
for (i = 0; i = 0) a[0] = scanbuffer[i - 1][j - 1];
}
if (i + 1 < h) {
a[5] = scanbuffer[i + 1][j];
if (j + 1 < w) a[4] = scanbuffer[i + 1][j + 1];
if (j - 1 >= 0) a[6] = scanbuffer[i + 1][j - 1];
}
if (j + 1 < w) a[3] = scanbuffer[i][j + 1];
if (j - 1 >= 0) a[7] = scanbuffer[i][j - 1];
//////////////////////////////////////////////count 1&2
for (int n = 0; n < 7; n++) {
if ((a[n] == 0) && (a[n + 1] == 1))
count_step_2++;
count_step_1 = count_step_1 + a[n];
}
if ((a[7] == 0) && (a[0] == 1)) count_step_2++;
count_step_1 = count_step_1 + a[7];
//////////////////////////////////p1 p2
p1 = a[1] * a[3] * a[5];
p2 = a[3] * a[5] * a[7];
if ((count_step_2 == 1) && ((count_step_1 >= 2) && (count_step_1 = (yMax + yMin) / 2 - 1)check = 1;
}
else ++iCount[check];
}
if (iCount[0] >= yMax-yMin-1 || iCount[0] >= 3 && iCount[1] >= 3 && iCount[0] + iCount[1] >= 7)
{
wCount[0] = 2;
}
else if (iCount[0] >= (yMax-yMin)/2 && iCount[0] = 4 ||
iCount[1] >= 4 && iCount[0] < 4)
{
if (hCount == 3 && iCount[0] < 4 && iCount[1] >= 4 && wCount[0] == 0)
{
MABANGZIN[LineNum*3+Num]=2;
MABANCHECK[LineNum*3+Num]=2;
return;
}
wCount[0] = 1;
}
}
if (wCount[1] != 2)
{
iCount[0] = iCount[1] = 0;
check = 0;
for (int j = yMin; j 0)
{
++check;
if (check > 1)break;
continue;
}
if (j >= (yMax + yMin) / 2 - 1)check = 1;
}
else ++iCount[check];
}
if (iCount[0] >= yMax - yMin - 1 || iCount[0] >= 3 && iCount[1] >= 3 && iCount[0] + iCount[1] >= 7)
{
wCount[1] = 2;
}
else if (iCount[0] >= (yMax-yMin)/2 && iCount[0] = 4 ||
iCount[1] >= 4 && iCount[0] < 4)
{
if (hCount == 3 && iCount[1] < 4 && iCount[0] >= 4 && wCount[0]==1)
{
MABANGZIN[LineNum*3+Num]=2;
MABANCHECK[LineNum*3+Num]=2;
return;
}
wCount[1] = 1;
}
}
}
if (wCount[0] == 2 && wCount[1] == 2)
{
MABANGZIN[LineNum*3+Num]=8;
MABANCHECK[LineNum*3+Num]=2;
return;
}
if (hCount == 1 && wCount[0] == 0 && wCount[1] == 2)
{
MABANGZIN[LineNum*3+Num]=7;
MABANCHECK[LineNum*3+Num]=2;
return;
}
if (hCount == 1 && wCount[0] == 1 && wCount[1] == 2)
{
MABANGZIN[LineNum*3+Num]=4;
MABANCHECK[LineNum*3+Num]=2;
return;
}
if (hCount == 3 && wCount[0] == 1 && wCount[1] == 1)
{
MABANGZIN[LineNum*3+Num]=5;
MABANCHECK[LineNum*3+Num]=2;
return;
}
if (hCount == 3 && wCount[0] == 2 && wCount[1] == 1)
{
MABANGZIN[LineNum*3+Num]=6;
MABANCHECK[LineNum*3+Num]=2;
return;
}
if (hCount == 3 && wCount[0] == 1 && wCount[1] == 2)
{
MABANGZIN[LineNum*3+Num]=9;
MABANCHECK[LineNum*3+Num]=2;
return;
}
if (hCount == 3 && wCount[0] == 0 && wCount[1] == 2)
{
MABANGZIN[LineNum*3+Num]=3;
MABANCHECK[LineNum*3+Num]=2;
return;
}
MABANGZIN[LineNum*3+Num]=0;
MABANCHECK[LineNum*3+Num]=0;
}
void check_error1() {
int i,j,k;
int check[4] = { 0,0,0,0 };
j=0;
k=0;
for(i=0;i9) m = 1;
} while ((MABANGZIN[0] == MABANGZIN[1]) ||
(MABANGZIN[0] == MABANGZIN[3]) ||
(MABANGZIN[0] == MABANGZIN[4]) ||
(MABANGZIN[0] == MABANGZIN[5]) ||
(MABANGZIN[0] == MABANGZIN[7]));
MABANGZIN[8] = 10 - MABANGZIN[0];
if ((15 - MABANGZIN[0] - MABANGZIN[3]) == (15 - MABANGZIN[7] - MABANGZIN[8])) {
MABANGZIN[6] = 15 - MABANGZIN[0] - MABANGZIN[3];
MABANCHECK[6] = 1;
MABANGZIN[2] = 15 - MABANGZIN[0] - MABANGZIN[1];
MABANCHECK[2] = 1;
MABANCHECK[0]=1;
MABANCHECK[8]=1;
break;
}
}
}
}
void check_error2() {
int i,j;
int check2[9];
int k = 0;
for (i = 0; i < 3; ++i) {
for (j = 0; j < 3; ++j) {
check2[k] = MABANGZIN[i * 3 + j];
++k;
}
}
for (i = 0; i < 8; ++i) {
for (j = i + 1; j