This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def SolveLinearEquationSystem(coeffMatrix, valVector): | |
# create the augmented matrix | |
augMatrix = [] | |
for i in range(0, len(coeffMatrix)): | |
augMatrix.append(coeffMatrix[i] + [valVector[i]]) | |
for i in range(0, len(augMatrix) - 1): | |
# find row containing largest ith col ele then swap with row i | |
# ensure scaling factor will never exceed 1 | |
# otherwise, round-off error may be bring about due to different magnitude order |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
2.58 | |
just test byte order | |
*/ | |
int is_big_endian() | |
{ | |
unsigned short b = 0x1234; | |
byte* pb = (byte*)&b; | |
if (*pb == 0x12) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int APIENTRY _tWinMain(HINSTANCE hInstance, | |
HINSTANCE hPrevInstance, | |
LPTSTR lpCmdLine, | |
int nCmdShow) | |
{ | |
UNREFERENCED_PARAMETER(hPrevInstance); | |
UNREFERENCED_PARAMETER(lpCmdLine); | |
return DialogBox(hInstance, MAKEINTRESOURCE(IDD_DLGMAIN), NULL, DlgProc); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <algorithm> | |
#include <Windows.h> | |
class MT_Queue { | |
public: | |
MT_Queue(int maxElements); | |
~MT_Queue(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const wstring SHUTDOWN_ACK = L"Server Shutdown"; | |
HANDLE g_requestSubmitted; | |
HANDLE g_requestReturned; | |
HWND g_mainDlg; | |
wstring g_requestText; | |
UINT APIENTRY ServerThreadFunc(PVOID param) | |
{ | |
bool isShutdown = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* remove non-alphabet from head and tail */ | |
int main() | |
{ | |
const char* alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
string text; | |
while (cin >> text) { | |
string::size_type begin = text.find_first_of(alphabet); | |
string::size_type end = text.find_last_of(alphabet) + 1; | |
text = text.substr(begin, end - begin); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/************************************ | |
** Edition: Demo | |
** Author: Kingsley Chen | |
** Date: 2013/11/19 | |
** Purpose: I/O issuer | |
************************************/ | |
#include "stdafx.h" | |
#include <conio.h> | |
#include <string> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MT_Queue { | |
public: | |
struct ELEMENT { | |
int thread_num; | |
int request_num; | |
}; | |
typedef ELEMENT* PELEMENT; | |
MT_Queue(int max_elements); | |
~MT_Queue(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding: utf-8 | |
# This file is part of Adblock Plus <http://adblockplus.org/>, | |
# Copyright (C) 2006-2013 Eyeo GmbH | |
# | |
# Adblock Plus is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License version 3 as | |
# published by the Free Software Foundation. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int StrToDecInt(const char* str) | |
{ | |
static const int kMAX = (int)((unsigned)~0 >> 1); | |
static const int kMIN = -(int)((unsigned)~0 >> 1) - 1; | |
static const int kMAX_DIV = (int)((unsigned)~0 >> 1) / 10; | |
static const int kMIN_DIV = (int)((((unsigned)~0 >> 1) + 1) / 10); | |
static const int kMAX_R = (int)((unsigned)~0 >> 1) % 10; | |
static const int kMIN_R = (int)((((unsigned)~0 >> 1) + 1) % 10); | |
int n = 0; |