Exemplo n.º 1
0
void BoardStatus::updateStatus()
{
    clearBoardFlag();
    QPoint chess(0, 0);

    for (int i = 0; i < boardSize; i++)
    {
        for (int j = 0; j < boardSize; j++)
        {
            if (!haveChess(i, j))
            {
                continue;
            }
            chess.setX(i);
            chess.setY(j);
            checkChessStatus(chess, LR);
            checkChessStatus(chess, TB);
            checkChessStatus(chess, LO);
            checkChessStatus(chess, RO);
        }
    }

/*
    for (int i = 0; i < chessTypeNum; i++)
    {
        qDebug() << "BLACK--" << numOfTypesBlack[i] << i;
        qDebug() << "WHITE--" << numOfTypesWhite[i] << i;
    }
*/
}
Exemplo n.º 2
0
Arquivo: texture.c Projeto: sbran/42
t_k	*texture(t_objet obj3, t_k *k, int text)
{
  if (text == 1)
    k = chess(obj3, k);
  else if (text == 2)
    k = ring(obj3, k);
  return (k);
}
Exemplo n.º 3
0
int main()
{
    scanf("%d",&n);
    scanf("%d",&m);
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            chess(i,j);
        }
    }
    return 0;
}
int main(){

    long n; scanf("%ld", &n);
    std::vector<std::pair<long, long> > chess(n);
    for(long p = 0; p < n; p++){scanf("%ld %ld", &chess[p].first, &chess[p].second);}

    long m; scanf("%ld", &m);
    std::vector<std::pair<long, long> > prog(m);
    for(long p = 0; p < m; p++){scanf("%ld %ld", &prog[p].first, &prog[p].second);}

    sort(chess.begin(), chess.end(), scmp);
    sort(prog.begin(), prog.end());
    long t1 = prog.back().first - chess[0].second;
    t1 = (t1 > 0) ? t1 : 0;

    sort(prog.begin(), prog.end(), scmp);
    sort(chess.begin(), chess.end());
    long t2 = chess.back().first - prog[0].second;
    t2 = (t2 > 0) ? t2 : 0;

    printf("%ld\n", ((t1 > t2) ? t1 : t2));

    return 0;
}
Exemplo n.º 5
0
/*======================================================================*
                               TestA
 *======================================================================*/
void TestA()
{
	int fd;
	int i, n;

	char filename[MAX_FILENAME_LEN+1] = "blah";
	const char bufw[] = "abcde";
	const int rd_bytes = 3;
	char bufr[rd_bytes];

	assert(rd_bytes <= strlen(bufw));

	/* create */
	fd = open(filename, O_CREAT | O_RDWR);
	assert(fd != -1);
	printl("File created: %s (fd %d)\n", filename, fd);

	/* write */
	n = write(fd, bufw, strlen(bufw));
	assert(n == strlen(bufw));

	/* close */
	close(fd);

	/* open */
	fd = open(filename, O_RDWR);
	assert(fd != -1);
	printl("File opened. fd: %d\n", fd);

	/* read */
	n = read(fd, bufr, rd_bytes);
	assert(n == rd_bytes);
	bufr[n] = 0;
	printl("%d bytes read: %s\n", n, bufr);

	/* close */
	close(fd);

	char * filenames[] = {"/foo", "/bar", "/baz"};

	/* create files */
	for (i = 0; i < sizeof(filenames) / sizeof(filenames[0]); i++) {
		fd = open(filenames[i], O_CREAT | O_RDWR);
		assert(fd != -1);
		printl("File created: %s (fd %d)\n", filenames[i], fd);
		close(fd);
	}

	char * rfilenames[] = {"/bar", "/foo", "/baz", "/dev_tty0"};

	/* remove files */
	for (i = 0; i < sizeof(rfilenames) / sizeof(rfilenames[0]); i++) {
		if (unlink(rfilenames[i]) == 0)
			printl("File removed: %s\n", rfilenames[i]);
		else
			printl("Failed to remove file: %s\n", rfilenames[i]);
	}
	
	TestD();

	
	

	char tty_name[] = "/dev_tty0";

	char rdbuf[128];


	int fd_stdin  = open(tty_name, O_RDWR);
	assert(fd_stdin  == 0);
	int fd_stdout = open(tty_name, O_RDWR);
	assert(fd_stdout == 1);

//	char filename[MAX_FILENAME_LEN+1] = "zsp01";
	const char bufwns[80] = {0};
//	const int rd_bytes = 3;
//	char bufr[rd_bytes];
	
	clear();
	welcome();
	
	while (1) {
		printl("hunix->");
		int r = read(fd_stdin, rdbuf, 70);
		rdbuf[r] = 0;
		//show();
		if (strcmp(rdbuf, "process") == 0)
		{
			ProcessManage();
		}
		else if(strcmp(rdbuf, "TextBook") == 0)
		{
			TextBook(fd_stdin, fd_stdout);
		}
		else if (strcmp(rdbuf, "filemng") == 0)
		{
			printf("File Manager is already running on CONSOLE-1 ! \n");
			continue;

		}else if (strcmp(rdbuf, "help") == 0)
		{
			help();
		}
		else if (strcmp(rdbuf, "NewFile") == 0)
		{

			NewFile(fd_stdin, fd_stdout);
		}
		else if(strcmp(rdbuf, "RemoveFile") == 0)
		{
			RemoveFile(fd_stdin, fd_stdout);
		}
		else if(strcmp(rdbuf, "WriteFile") == 0)
		{
			WriteFile(fd_stdin, fd_stdout);
		}
		else if(strcmp(rdbuf, "ReadFile") == 0)
		{
			ReadFile(fd_stdin, fd_stdout);
		}
		else if(strcmp(rdbuf, "Chess") == 0)
		{
			chess(fd_stdin, fd_stdout);
		}
		else if(strcmp(rdbuf, "Add") == 0)
		{
			Add(fd_stdin, fd_stdout);
		}
		else if(strcmp(rdbuf, "welcome") == 0)
		{
			welcome();
		}
		else if(strcmp(rdbuf, "number") == 0)
		{
			number(fd_stdin, fd_stdout);
		}
		else if (strcmp(rdbuf, "clear") == 0)
		{
			clear();
			
		}
		else
			printf("Command not found, please check!\n");
	}
	

	spin("TestA");
}