All pastes #277125 Raw Edit

Unnamed

public cpp v1 · immutable
·published 2006-12-12 22:50 UTC
rendered paste body
char check4x4(char t[4][4]){  //vodoravno in navpicno  for (int i = 0; i < 4; i++){      if ((t[i][0] == t[i][1]) && (t[i][2] == t[i][3]) && (t[i][0] == t[i][2]))         if (t[i][0]!= 0)		//ce tabela ni prazna, je nekdo postavil 4 v vrsto				return t[i][0];      if ((t[0][i] == t[1][i]) && (t[2][i] == t[3][i]) && (t[0][i] == t[2][i]))	     if (t[0][i]!= 0)		//ce tabela ni prazna, je nekdo postavil 4 v vrsto			return t[0][i];      }  //diagonali  if ((t[0][0] == t[1][1]) && (t[2][2] == t[3][3]) && (t[0][0] == t[2][2]))     if (t[0][0]!=0)		//ce tabela ni prazna, je nekdo postavil 4 v vrsto			return t[0][0];  if ((t[0][3] == t[1][2]) && (t[2][1] == t[3][0]) && (t[0][3] == t[2][1]))     if (t[0][3]!=0)		//ce tabela ni prazna, je nekdo postavil 4 v vrsto			return t[0][3];  return 0;		//nihce ni zmagal}char connectFour2(){	char tempTab[4][4];	char won = 0;	for(int R=0; R<(ROW-3); R++){		for(int C=0; C<(COLUMN-3); C++){			for(int i=0; i<4; i++){				for(int j=0; j<4; j++){					tempTab[j][i] = board[C+j][R+i];				}			}			won = check4x4(tempTab);			if(won != 0)				return won;		}	}	return won;}char connectFour(){	int x = Cglobal;	int y = Rglobal;	char color = board[Cglobal][Rglobal];	int temp = -1;	int count2 = 0;	//preveri ce se nahajajo stirje zetoni v vrsti, kamor je padel zadnji zeton	for(int i=0; i<COLUMN; i++){		if(board[i][Rglobal] == color){			if(++count2 == 4)				return color;		}else			count2 = 0;	}	//navpicno od trenutnega zetona navzdol	if((Rglobal+3) < ROW){		count2 = 0;		for(int i=Rglobal; i<Rglobal+4; i++){			if(board[Cglobal][i] == color)				count2++;		}		if(count2 >=4)			return color;	}	//diagonala desno-navzdol	int Xstart1 = x;	int Ystart1 = y;	while((Xstart1 > 0) && (Ystart1 > 0)){		Xstart1--;		Ystart1--;	}	while((Xstart1 < COLUMN) && (Ystart1 < ROW)){			//zacne v tocki (0,0)		count2 = 0;		for(int i=0; i<4; i++){			if(board[Xstart1++][Ystart1++] == color){				if(++count2 == 4)					return color;			}else{				count2 = 0;				break;			}			if((Xstart1 >= COLUMN) || (Ystart1 >= ROW))				break;		}	}	//diagonala desno-navzgor	int Xstart2 = x;	int Ystart2 = y;	//R	while((Xstart2 > 0) && (Ystart2 < ROW)){		Xstart2--;		Ystart2++;	}	while((Xstart2 < COLUMN) && (Ystart2 >= 0)){			//zacne od levega spodnjega kota (0,7)		count2 = 0;		for(int i=0; i<4; i++){			if(board[Xstart2++][Ystart2--] == color){				if(++count2 == 4)					return color;			}else{				count2 = 0;				break;			}			if((Xstart2 >= COLUMN) || (Ystart2 < 0))				break;		}	}	return 0;}