0
1 2 3 4 5 6 7 8 9 10 11
bool MyProc::CompareModule(int *operand1, int *operand2, int n) {
for (int i = 1; i < n; i++) {
if (operand1[i] != operand2[i]) {
if (operand1[i] < operand2[i])
return false;
else
return true;
};
};
return true;
};
guest ,
10.12.2008 (Updated 24.03.2018 )
0
1 2 3 4 5 6 7 8 9
if(dOper1p->Caption == "-0")
dOper1p->Caption = "+0";
if(dOper2p->Caption == "-0")
dOper2p->Caption = "+0";
if(dOper1m->Caption == "-0.0")
dOper1m->Caption = "+0.0";
if(dOper2m->Caption == "-0.0")
dOper2m->Caption = "+0.0";
типичный представитель говнокода
guest ,
10.12.2008 (Updated 24.03.2018 )
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
//разметка матрицы
while ((founded==1)&&(mat[nx][ny]<=0)) {
founded=0;
iii=y-i;
while (((i==0)&&(iii==y))||((iii<=y+i))){
ii=x-i;
while ((ii<=x+i)){
if ((mat[ii][iii]==i)&&((ii<70)&&(ii>=0))&&((iii<70)&&(iii>=0))) {
bii=ii;
biii=iii;
if ((mat[bii+1][biii]==-1)&&(bii+1<70)&&(bii+1>=0)) {
mat[bii+1][biii]=i+1;
founded=1;
}
if ((mat[bii-1][biii]==-1)&&(bii-1<70)&&(bii-1>=0)) {
mat[bii-1][biii]=i+1;
founded=1;
}
if ((mat[bii][biii+1]==-1)&&(biii+1<70)&&(biii+1>=0)) {
mat[bii][biii+1]=i+1;
founded=1;
}
if ((mat[bii][biii-1]==-1)&&(biii-1<70)&&(biii-1>=0)) {
mat[bii][biii-1]=i+1;
founded=1;
}
}
ii++;
}
iii++;
}
i++;
}
if (mat[nx][ny]>=0) {
if ((nx==40)&&(ny==57)) {
nx=nx;
}
ik=i;
ii=nx;
iii=ny;
//поиск пути
while (ik>1) {
if ((mat[ii-1][iii]==ik-1)&&(ii-1<70)&&(ii-1>=0)) {
ii--;
mat[ii][iii]=-3;
}
if ((mat[ii][iii-1]==ik-1)&&(iii-1<70)&&(iii-1>=0)) {
iii--;
mat[ii][iii]=-3;
}
if ((mat[ii+1][iii]==ik-1)&&(ii+1<70)&&(ii+1>=0)) {
ii++;
mat[ii][iii]=-3;
}
if ((mat[ii][iii+1]==ik-1)&&(iii+1<70)&&(iii+1>=0)) {
iii++;
mat[ii][iii]=-3;
}
ik--;
}
ax=ii*10+5;
ay=iii*10+5;
//out_to_file(mat,"d:\\out.txt");
i++;
ii=0;
iii=0;
while ((iii>-1)&&(iii<70)){
ii=0;
while ((ii>-1)&&(ii<70)){
if ((mat[ii][iii]>-1)||(mat[ii][iii]==-3)) {
mat[ii][iii]=-1;
}
ii++;
}
iii++;
}
nx=ax;
ny=ay;
} else ...
}
Разметка матрицы, Поиск Пути.
guest ,
08.12.2008 (Updated 24.03.2018 )
0
1 2 3 4
if (result == true)
return true;
else
return result;
этпипец... из разряда индокода, только в реале
guest ,
04.12.2008 (Updated 24.03.2018 )
0
1 2 3 4 5 6 7 8
void ListViewCtrl::SetEditableColumn(int col, bool editable)
{
while(col >= static_cast<int>(editableCols_.size()))
{
editableCols_.push_back(true);
}
editableCols_[col] = editable;
}
std::vector<bool> editableCols_;
вектор булов используется в ListView для того чтобы указать является ли столбец редактируемым...
p.s. польские паттерны)
guest ,
02.12.2008 (Updated 24.03.2018 )
0
1 2 3 4 5 6 7 8 9
QString newText=text;
if (weShouldIgnoreSpaces())
newText.replace(QString(" "),QString("%"));
delete modelAnswer;
delete modelQuestion;
modelAnswer = new QSqlQueryModel(0);
modelQuestion = new QSqlQueryModel(0);
questionOutput->setModel(modelQuestion);
answerOutput->setModel(modelAnswer);
Кусочек кода на C++/Qt, чтобы SQLite успевал закончить обработку прошлого запроса перед новым. Как ни странно помогало...
guest ,
01.12.2008 (Updated 24.03.2018 )
0
1 2 3 4 5 6 7 8 9 10 11 12 13
static HRESULT SResToHRESULT(SRes res)
{
switch(res)
{
case SZ_OK: return S_OK;
case SZ_ERROR_MEM: return E_OUTOFMEMORY;
case SZ_ERROR_PARAM: return E_INVALIDARG;
case SZ_ERROR_UNSUPPORTED: return E_NOTIMPL;
// case SZ_ERROR_PROGRESS: return E_ABORT;
case SZ_ERROR_DATA: return S_FALSE;
}
return E_FAIL;
}
(c) 7z
guest ,
01.12.2008 (Updated 24.03.2018 )
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
typedef struct tagRECT{
LONG left;
LONG top;
LONG right;
LONG bottom;
} RECT, *PRECT, NEAR *NPRECT, FAR *LPRECT;
typedef const RECT FAR* LPCRECT;
typedef struct _RECTL{
LONG left;
LONG top;
LONG right;
LONG bottom;
} RECTL, *PRECTL, *LPRECTL;
typedef const RECTL FAR* LPCRECTL;
Вот так тайпдефятся абсолютно одинаковые структуры в windef.h
guest ,
28.11.2008 (Updated 24.03.2018 )
0
1 2 3
uint32_t getuint32(char *p){
return (*p<<24)|(*(p+1)<<16)|(*(p+2)<<8)|(*(p+3));
}
guest ,
27.11.2008 (Updated 24.03.2018 )
0
1 2 3 4 5 6 7 8 9 10
//
// true - success
// false - value not found for given key
//
bool CATStorage::getValueForKey(const std::string &key, std::string &value) const
{
...
std::string().swap(value);
...
}
Код очистки содержимого строки, C++, STL
guest ,
27.11.2008 (Updated 24.03.2018 )