Exemple #1
0
void LpaStar::updateAllKeyValues(){	
	for(int i=0; i < rows; i++){
	   for(int j=0; j < cols; j++){
		   calcKey(&maze[i][j]);
		}
	}
	
	calcKey(start);
	calcKey(goal);
}
void TCalcDisplay::handleEvent(TEvent& event)
{
    TView::handleEvent(event);

    switch(event.what)
        {
        case evKeyboard:
            calcKey(event.keyDown.charScan.charCode);
            clearEvent(event);
            break;
        case evBroadcast:
            if(event.message.command == cmCalcButton)
                {
                calcKey( ((TButton *) event.message.infoPtr)->title[0]);
                clearEvent(event);
                }
            break;
        }
}
void EditorScene::shadingTriangle(cocos2d::Vec2 rawpos)
{
    clearSelection();
    auto tri = findTriangle(rawpos);
    if (tri) {
        _triangleColorMap[_frameIndex][tri->calcKey()] = _diggingColor;
        tri->color = _diggingColor;
        refreshTriangles();
    }
}
void EditorScene::diggColor(cocos2d::Vec2 rawpos)
{
    clearSelection();
    float radio = 1.0*rawpos.x/1024.0;
    if (radio < 0.05) {
        radio = 0;
    }
    if (rawpos.y < 44) {
        _diggingColor.w = radio;
    } else if (rawpos.y < 44*2) {
        _diggingColor.z = radio;
    } else if (rawpos.y < 44*3) {
        _diggingColor.y = radio;
    } else if (rawpos.y < 44*4) {
        _diggingColor.x = radio;
    } else if (rawpos.y > 256) {
        auto tri = findTriangle(rawpos);
        if (tri) {
            _diggingColor = _triangleColorMap[_frameIndex][tri->calcKey()];
        }
    }
    refreshDiggColor();
}
int main()
{
	std::cout << "On calc prime num ... " << std::endl;
	createprime();
	std::cout << "On calc key ... " << std::endl;
	calcKey();
	bool * testbool = new bool[7]{
		true, false, false,
			false, true, false, true
	};
	std::cout << "before encryption:" << std::endl;
	outputboolarray(testbool,7);
	std::cout << std::endl;
	BinNum R = Encrypt(testbool, 7);
	std::cout << "after encryption:" << std::endl;
	outputB(R);
	BinNum dec = Decrypt(R);
	std::cout << "after decryption:" << std::endl;
	outputB(dec);
	std::cout << "if decryption is not equal the test ,may be overflow on calc (a+b) % n, i can't fix it,sorry for that" << std::endl;
	system("pause");
	return 0;
}