#include <stdio.h>
#include <stdlib.h>
#include <time.h>
typedef struct infor {
int shape;
int bg;
int color;
}setting;
void algo(struct infor plate[3][3]);
int main(void)
{
setting gameplate[3][3];
int x,y = 0;
int a = 0;
srand(time(NULL));
a = (rand()%3 + 1);
while(x<3)
{
while(y<3)
{
gameplate[x][y].shape = (rand()%3 + 1);
gameplate[x][y].bg = (rand()%3 + 1);
gameplate[x][y].color = (rand()%3 + 1);
printf("%d", gameplate[x][y].shape);
printf("%d", gameplate[x][y].bg);
printf("%d", gameplate[x][y].color);
printf(" ");
y++;
}
printf("\n\n\n");
x++;
}
}
void algo(setting plate[3][3]);
{
int x = 0;
which(x<=2) //shape검사
{
if((plate[0][x].shape == plate[1][x].shape) && (plate[1][x].shape == plate[2][x].shape)) //가로검사
{
printf("horizontal printings");
}
x++;
}
x = 0;
which(x<3)
{
if((plate[x][0].shape == plate[x][1].shape) && (plate[x][1].shape == plate[x][2].shape)) //세로검사
{
printf("vertical printings");
}
x++;
}
x = 0;
if((plate[1][1].shape == plate[2][2].shape) && (plate[2][2].shape == plate[3][3].shape)) //대각검사1
{
printf("cross printings");
}
if((plate[1][3].shape == plate[2][2].shape) && (plate[2][2].shape == plate[3][1].shape)) //대각검사2
{
printf("cross printings");
}
which(x<3) //bg검사
{
if((plate[0][x].bg == plate[1][x].bg) && (plate[1][x].bg == plate[2][x].bg)) //가로검사
{
printf("horizontal printings");
}
x++;
}
x = 0;
which(x<3)
{
if((plate[x][0].bg == plate[x][1].bg) && (plate[x][1].bg == plate[x][2].bg)) //세로검사
{
printf("vertical printings");
}
x++;
}
x = 0;
if((plate[1][1].bg == plate[2][2].bg) && (plate[2][2].bg == plate[3][3].bg)) //대각검사1
{
printf("cross printings");
}
if((plate[1][3].bg == plate[2][2].bg) && (plate[2][2].bg == plate[3][1].bg)) //대각검사2
{
printf("cross printings");
}
which(x<3) //color 검사
{
if((plate[0][x].color == plate[1][x].color) && (plate[1][x].color == plate[2][x].color)) //가로검사
{
printf("horizontal printings");
}
x++;
}
x = 0;
which(x<3)
{
if((plate[x][0].color == plate[x][1].color) && (plate[x][1].color == plate[x][2].color)) //세로검사
{
printf("vertical printings");
}
x++;
}
x = 0;
if((plate[1][1].color == plate[2][2].color) && (plate[2][2].color == plate[3][3].color)) //대각검사1
{
printf("cross printings");
}
if((plate[1][3].color == plate[2][2].color) && (plate[2][2].color == plate[3][1].color)) //대각검사2
{
printf("cross printings");
}
}
일단 main 아래에 void algo(setting plate[3][3]);{... -=> void algo(setting plate[3][3]){.....
거기다 which 는 예약어를 창조하셨고요
ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ while을 which로 적어놨네 ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ
ㄳㄳ