- 1
for (size_t i=v.size()-1; i<v.size(); --i)
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+56
for (size_t i=v.size()-1; i<v.size(); --i)
unsigned в массивах не нужен, нахуй усрались длинные массивы?
+60
Объявление:
bool getBorderThickness() const {return isThinBorder;}
Использование:
size += !getBorderThickness();// + 2;
visibleAreaBegin.x = getLTPoint().x + xLeftShift + !getBorderThickness();
visibleAreaWidth = getRBPoint().x - getLTPoint().x - xRightShift - xLeftShift - 2*!getBorderThickness();
Умножать на буль - айм ловинг щит!
+54
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
int main()
{
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
long x1, x2, x3;
cin >> x1 >> x2 >> x3;
if(x1 == 0 && x2 == 0 && x3 == 0){
cout << 0 << endl;
exit(EXIT_SUCCESS);
}
(x1 != 0) ? cout << x1 : cout << "";
(x2 != 0) ? (x2 > 0 && x1 != 0) ? (x2 == 1) ? cout << "+x" : cout << '+' << x2 << 'x' : (x2 == -1) ? cout << "-x" : (x2 == 1) ? cout << 'x' : (x2 == -1) ? cout << "-x" : cout << x2 << 'x' : cout << "";
(x3 != 0) ? (x3 == 1) ? cout << 'y' : (x3 == -1) ? cout << "-y" : (x2 == 0 && x1 == 0) ? cout << x3 << 'y' : (x3 > 0) ? (x3 == 1) ? cout << "+y" : cout << '+' << x3 << 'y' : (x3 == -1) ? cout << "-y" : cout << x3 << 'y' : cout << "";
cout << endl;
return 0;
}
Задача № 277 на acmp.ru. Решил "не писать много кода"
+64
void GetVoid()
{
return delete &"Возвращаем void";
};
Функция для получения void.
+64
delete new T;
убийство новорожденного
+53
// quick render params menu actions
if(pe->buttons()&Qt::LeftButton || pe->buttons()&Qt::RightButton){
//
if(cRenderMenuOpended){//
if((p.x()+p.y())<18){// - -
cRenderMenuOpended=!cRenderMenuOpended;
repaint();
return;
}
else if(p.x()>5 && p.y()>5 && p.x()<145 && p.y()<cRenderMenuHeight){// actions rectangle
//
//sliceModifyMode=true; // show slice plane and can be modified
//useSlicePlane=true; // build geometry with slice plane
if(cViewType==0){// 2D
if(p.x()>10 && p.y()>22 && p.x()<140 && p.y()<38){
// reset zoom
if(c2DZoom1To1){
cPanFor2DX1to1=0;
cPanFor2D=0;
cPanFor2DX=0;
cZoomFor2D=1;
if(cViewType==0 && c2DZoom1To1 && renderLimits){
auto testSizeX=cVieportXSize;
auto testSizeY=cVieportYSize;
BoundaryConditionsOfComposite *cond=NULL;
cond=AbstractContainer::getInstance()->getBoundaryCondition(0);
if(cond->isHeatFlux_multiple()){
cPanFor2D+=15;
testSizeY-=20;
}
if(cond->isHeatFlux_multiple() || cond->isHeatFlux() || cond->isHeatPower() || cond->isConvection() || cond->isInsulated() || cond->isTemperature()){
cPanFor2D+=20;
testSizeY-=25;
}
cond=AbstractContainer::getInstance()->getBoundaryCondition(3);
if(cond->isHeatFlux() || cond->isHeatPower() || cond->isConvection() || cond->isInsulated() || cond->isTemperature()){
testSizeX-=35;
cPanFor2DX1to1+=30;
}
cond=AbstractContainer::getInstance()->getBoundaryCondition(1);
if(cond->isHeatFlux() || cond->isHeatPower() || cond->isConvection() || cond->isInsulated() || cond->isTemperature()){
testSizeX-=35;
}
if(cWidth>cThikness){
cZoomFor2D=(double(testSizeX)-50.0)/(zoomed2DX(width_sub_start)-zoomed2DX(width_sub_end));
}
else{
cZoomFor2D=(double(testSizeY)-50.0)/(zoomed2DY(thickness_sub_start)-zoomed2DY(thickness_sub_end));
}
}
}
else{
cZoomFor2D=1;
cPanFor2D=0;
cPanFor2DX=0;
}
repaint();
return;
}
else if(p.x()>10 && p.y()>42 && p.x()<140 && p.y()<58){
cForbidRenderResultsOverLayers=!cForbidRenderResultsOverLayers;
repaint();
return;
}
else if(p.x()>10 && p.y()>62 && p.x()<140 && p.y()<78){
renderLimits++;
if(renderLimits>1){
renderLimits=0;
}
repaint();
return;
}
else if(p.x()>10 && p.y()>82 && p.x()<140 && p.y()<98){
SLOT_swap2DMode11AndScaled();
return;
}
else if(p.x()>106 && p.y()>92 && p.x()<122 && p.y()<118){
cResTransparency-=0.1;
if(cResTransparency<0){cResTransparency=0;}
repaint();
return;
}
else if(p.x()>124 && p.y()>92 && p.x()<140 && p.y()<118){
cResTransparency+=0.1;
if(cResTransparency>1){cResTransparency=1;}
repaint();
return;
}
}
else{//3D
if(p.x()>10 && p.y()>22 && p.x()<140 && p.y()<38){
slot_swapCoordiantes();
return;
}
else if(p.x()>10 && p.y()>42 && p.x()<140 && p.y()<58){
Магия чисел в построении GUI
+51
QVector<double*>*** ElemBoundCond = tbc->getElementsBC();
QVector<double*>* preNodalVals = tbc->getPreNodalValues();
QVector<double*>* nodalForces = tbc->getNodalForces();
long elems = grid->getElemsNumber();
long nodes = grid->getNodesNumber();
long** Elements = grid->getElems();
double** Nodes = grid->getNodes();
long* ElemMaters = grid->getElemsMaterials();
long NBW = grid->getBandWidth();
emit signal_addLineToCalculationProtocol(">>> Solve heat problem ");
long NS[4],//+numbers of 4 nodes
NCL = 1,//number or unknown values per node (1 for thermal analysis)
ni, nj, nk,//face nodes
gnN, dN;
double ESM[4][4],//+element stiffness matrix
EF[4],//+element force matrix
**C,//matrix conteins X, Y, Z coordinates, rows like |1 Xi Yi Zi|
**CA,//conteins columns like |ai bi ci di|
//*GF,//band matrix, pointers to Global Force and Global Sriffness Matrices in A
V36,//+hexa and 36 element volume
S_3,//face area div 3
hS_3, hS_6, hS_12,//h * face area div 6 and div 12
hST_3,//h * face area * T / 3
qS_3;//q * face area / 3
QVector<double*>* fcond;
MaterialsDatabase* matdb = MaterialsDatabase::getInstance();
double Kxx, Kyy, Kzz;//thermal condactivities in X, Y and Z axes
И снова фортранщина.
+57
void NestMathematica::DATABS(){
int ks1 = 0;
int ns1=0;
int ns=0;
ia=-1;
ia=ia+1;
b[ia]=-ak[0];
ia=ia+1;
b[ia]=alfa;
mud=1;
mld=1;
if(ks!=1){
ia=ia+1;
b[ia]=0.;
ks1=ks-1;
for(int i=0; i<ks1; i++){
ns1=ns;
ns=ns+1;
if(ns!=1){
ia=ia+1;
b[ia]=0.;
}
ia=ia+1;
b[ia]=ak[ns1];
ia=ia+1;
b[ia]=0.;
ia=ia+1;
b[ia]=-ak[ns];
ia=ia+1;
b[ia]=0.;
ia=ia+1;
b[ia]=h[ns1];
ia=ia+1;
b[ia]=1.;
ia=ia+1;
b[ia]=0.;
ia=ia+1;
b[ia]=-1.;
if(ns!=ks){
ia=ia+1;
b[ia]=0.;
}
}
mud=2;
mld=2;
ia=ia+1;
b[ia]=0.;
} //10
if(beta<0){
ia=ia+1;
b[ia]=h[ks-1];
ia=ia+1;
b[ia]=1.;
}else{
ia=ia+1;
b[ia]=ak[ks]+beta*h[ks];
ia=ia+1;
b[ia]=beta;
}
return;
}
Программист на фортране может программировать на любом языке... как на фортране.
+52
double cCompositeBlock::determinant4x4(double *d){ // WARNING It's not logically connected with class.
return d[3]*d[6]*d[9]*d[12] -d[2]*d[7]*d[9]*d[12]-
d[3]*d[5]*d[10]*d[12] +d[1]*d[7]*d[10]*d[12]+
d[2]*d[5]*d[11]*d[12] -d[1]*d[6]*d[11]*d[12]-
d[3]*d[6]*d[8]*d[13] +d[2]*d[7]*d[8]*d[13]+
d[3]*d[4]*d[10]*d[13] -d[0]*d[7]*d[10]*d[13]-
d[2]*d[4]*d[11]*d[13] +d[0]*d[6]*d[11]*d[13]+
d[3]*d[5]*d[8]*d[14] -d[1]*d[7]*d[8]*d[14]-
d[3]*d[4]*d[9]*d[14] +d[0]*d[7]*d[9]*d[14]+
d[1]*d[4]*d[11]*d[14] -d[0]*d[5]*d[11]*d[14]-
d[2]*d[5]*d[8]*d[15] +d[1]*d[6]*d[8]*d[15]+
d[2]*d[4]*d[9]*d[15] -d[0]*d[6]*d[9]*d[15]-
d[1]*d[4]*d[10]*d[15] +d[0]*d[5]*d[10]*d[15];
}
+50
if (tp==-1 || c==a[tp]-'a') tp++; else {
l[ts+1]=la; p[ts+1]=ts;
l[ts]=l[tv]; r[ts]=tp-1; p[ts]=p[tv]; t[ts][c]=ts+1; t[ts][a[tp]-'a']=tv;
l[tv]=tp; p[tv]=ts; t[p[ts]][a[l[ts]]-'a']=ts; ts+=2;
tv=s[p[ts-2]]; tp=l[ts-2];
while (tp<=r[ts-2]) { tv=t[tv][a[tp]-'a']; tp+=r[tv]-l[tv]+1;}
if (tp==r[ts-2]+1) s[ts-2]=tv; else s[ts-2]=ts;
tp=r[tv]-(tp-r[ts-2])+2; goto suff;
}
Говнокод олимпиадный.
http://e-maxx.ru/algo/ukkonen