- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
foreach($succes_type as $value) {
if (strcasecmp($typefile, $value) == 0) $resultat = 1;
}
# Проверка загружаемого
if($resultat != 1 OR $resultat == null OR $resultat == 0) {
...
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+56
foreach($succes_type as $value) {
if (strcasecmp($typefile, $value) == 0) $resultat = 1;
}
# Проверка загружаемого
if($resultat != 1 OR $resultat == null OR $resultat == 0) {
...
}
$resultat выше не определялась...
+56
#/* */include<stdio.h>
/* */int/**/main(int/**/o,char**O){int y[4],
r[4] ,z[4],C,h,i,n,a,t,s,u[2][3][4]={{{6,9,0,3} ,
{ 1,10,4,7},{5,11,2,8}},{{3,0,6,9},{10,1,4,7},{ 8,2,5
,11}}}, M,I,R,A,K,U[2],RU[2],N[2],_=2;FILE*x[03] ; unsigned/*,
*/char/**/ p[2][3<<16],d[12],b[256][256];float/**/f,q [12];if((o<4)){
return!puts("<a.ppm>\40<b.ppm>\40<output.ppm>\40[odd]") ;}else{for(h=0;h<2;
h++){M=SEEK_SET;if(!(x[h]=fopen(O[h+1],"rb")))goto/**/e;if( (int)fread(*b,1,256,x[h
])<1||sscanf((char*)*b,*O="P6\n%d\40%d\n%d\n",&U[h],&N[h],&i)-3||i-255)goto/**/e;for(
i=C=RU[h]=0;i<256&&!RU[h];i++)if(b[0][i]=='\n')if(++C==3)fseek(x[h],RU[h]=i+1,M);if(!RU
[h]||U[h]<1||U[h]>(1<<16))goto/**/e;}if(*U-U[1]||*N-N[1])goto/**/s;for(h=0;h<256;h++)for(
i=0;i<256;b[h][i++]=0) ;for(i=0;i<*N;i++){for(h=0;h<2;h++)if(fread(p[h],3**U,01,x[h])!=1)
goto/**/e;for(h=0;h<3** U;h++)b[p[0][h]][p[1][h]]=1; }*y=*r=y[2]=r[2]=64;y[1]=r[1]=y[3]=r[
3]=192;A=(y[1]-*y)*(y[ 3]-y[2]);for(M=64;M>0; M/=2) {for(t=-1;t<=0;t++)if((*z=*r+t*M)>-1)
for(I=-1;I<1;I++)if((z [ 2]=r[2]+I*M)> (-1)) for (s=1;s>-1;s--)if((z[1]=r[1]+s*M)<257
)for(R=1;R>-1;R--)if( + 257>(z[3]=r [3]+R* M) )if((K=(z[1]-z[0])*(z[3]-z[2]))>A){
for(h=C=0;h<256&&C> -1 &&C<256; h ++)for (n=h*(z[1]-z[i=0])/256+*z;C>-1&&
i<256&&C<256;i++){a = i*(z[3]-z [2 ])/256+ z[2];if(b[h][i])C=(3*n-a)/2;}if
(C>-1&&C<256)for(C =0 , A= K ;C <4;++ C)y[C]=z[C];}for(C=0;C<4;C++)r
[C]=y[C];}if(!(x[2 ] =/* */ fopen (O[03],"wb+")))goto/**/e;else{
fprintf(x[2],*O,2* *U,2**N,+ 255);for(h= 0;h<(2);h++)fseek(x[h],RU[h],
SEEK_SET);C=(o<5)? 1/***/:00 ;/***/R=1+( 1<<16);for(i=0;i<*N;i++){for(h
=0;h<2;h++)if(fread (/****/p[ h/****/],+3 **U,1,x[h])!=1)goto/**/e;for(
M=0;M<7;M+=6)for(h =/**/0;* U/**/>h;h ++){for(n=0;n<3;n++){for(a=0;
a<2;a++)q[u[C][n] [a]]=p [a][h *3+n]*(r[a*2+1]-r[a*2])/256.f
+r[a*2];q[u[C][n] [2]]=q[u[C][n][3]]=(3*q[*u[C][
n]]-q[u[C][n][1]] )/2;}for(n=0;n<12;d[n++]=t<0?
0:(t>255?255:t)){ t = q[n];f=q[n]-t;_=(_*75)%R;if(_<f
*R)++ t;}fwrite(d +M,6,1, x[2]);}}}}for(h=0;h<3;h =h + 1
) t= fclose(x [h ]); return (t*1);s :
*O ="si" /* */ "ze "; printf (
* /*' P*/ O); ;e : return
! /*w*/ puts /*;
*/("error"); }
http://uguu.org/sources.html юзайте ребята.
+55.9
while (true)
{
m_CurrentDevice += delta;
if (m_CurrentDevice < 0)
m_CurrentDevice = devices[DEV_PLATE]-1;
if (m_CurrentDevice > devices[DEV_PLATE]-1)
m_CurrentDevice = 0;
break;
}
Это конечно написано не специально - в результат целой кучи итераций и переделок. но результата это не отменяет
+55.6
0 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23 * * * root /usr/local/cron_func/trans.pl
строка в crontab'е.
+55.5
//------------------------------- COMPARE -------------------------------------
// Function to compare two strings on a mask, using a question mark and
// asterisk.Question mark matches any single character. The asterisk matches
// any signs of a minimum length of zero. maximum length is not limited. Only
// the next character in the mask has a value when there is a coincidence.
int compare(const char pat[],const char text[],int rec_ex)
{
bool flag = false; // flag show if working on "star"
int pat_len ,txt_len, // lehtghs of pattern and text
flagc, // counter and position i check
shift=0; // shift position
pat_len = (int)strlen(pat); // get lehtgh of pattern
txt_len = (int)strlen(text); // get lehtgh of text
if(rec_ex == 1 || (!pat_len && !txt_len)) // check if have to check some
return(1); // if yes return 1 or if have exit
else if(rec_ex == pat_len) // else return 0 becose not check that
return (0); // return 0
for(flagc=0;flagc < pat_len;flagc++)
if(pat[flagc] == '*' && flagc + 1 == pat_len)
return(compare(pat,text,1));// end of check return 1
else if(pat[flagc] == '*')
flag = true; // start * compare set flag true
else if(pat[flagc] != '?')
{
if(toupper(pat[flagc]) != toupper(text[flagc+shift]) && !flag)
return(compare(pat,text,pat_len)); // bad char and no star
else if(toupper(pat[flagc]) == toupper(text[flagc+shift]) && flag)
flag = false; // set flag false position
else if(toupper(pat[flagc]) != toupper(text[flagc+shift]) && flag)
shift++;
}
else if(pat[flagc] == '?')
{ // check if have ? in star operation
if(toupper(pat[flagc]) == toupper(text[flagc+shift]) && flag)
flag = false; // set flag false position
else if(toupper(pat[flagc]) != toupper(text[flagc+shift]) && flag)
shift++; // add one more into shift
}
if((flagc+shift < txt_len && !flag) // text have nore chars and
|| (flagc+shift == txt_len +1 && pat[pat_len+1] != '*'))
return(compare(pat,text,pat_len)); // and next char in pattern no star
else
return(compare(pat,text,1)); // end of pattern and text
}
Вот на после завтра нужно по программированию функцию написать- рекурсивную для сравнения строк по маске.
Написал :-) якобы рекурсивную функцию :-)
+55.5
class cCar: public GAMEPLAYER::cPlayerRef, public cScrObject,
public IspSetOnParkingPlace<GAMEPLAYER::cCar>,
public IspCheckLoadedState<GAMEPLAYER::cCar>,
// public IspUseInitialPositioning<GAMEPLAYER::cCar>,
public IspSetVelocity<GAMEPLAYER::cCar>,
public IspTracetoPosition<GAMEPLAYER::cCar>,
public IspChangeVehicle<GAMEPLAYER::cCar>,
public IspChasePlayer<GAMEPLAYER::cCar>,
public IspRaceParamsPlayer<GAMEPLAYER::cCar>,
public IcallbackParked<GAMEPLAYER::cCar>,
public ALTERNATIVEK::cstore_this<GAMEPLAYER::cCar>
{ //... дальше не интересно
Вот такой суровый cCar :)
+55.4
#include <math.h>
#include <assert.h>
#include "vector10d.h"
float vcompare_epsilon10d = 0.0005f;
ml inlined float v10d_getElement(vec10d *v, int index)
{
assert( v != 0);
assert( index >= 0 );
assert( index < 3 );
return (* ((&((v)->x)) + (index) ));
}
ml inlined bool v10d_isValid(const vec10d *v)
{
if(v == 0) return g_false;
if((v->x * v->x) < 0.0f)return g_false;
if((v->y * v->y) < 0.0f)return g_false;
if((v->z * v->z) < 0.0f)return g_false;
if((v->w * v->w) < 0.0f)return g_false;
if((v->m * v->m) < 0.0f)return g_false;
if((v->n * v->n) < 0.0f)return g_false;
if((v->o * v->o) < 0.0f)return g_false;
if((v->p * v->p) < 0.0f)return g_false;
if((v->r * v->r) < 0.0f)return g_false;
if((v->s * v->s) < 0.0f)return g_false;
return g_true;
}
ml inlined void v10d_set(vec10d *v, float x, float y, float z, float w, float m,
float n, float o, float p, float r, float s)
{
assert(v = 0);
v->x=x;
v->y=y;
v->z=z;
v->w=w;
v->m=m;
v->n=n;
v->o=o;
v->p=p;
v->r=r;
v->s=s;
assert( v10d_isValid(v) != g_false );
}
ml inlined void v10d_get(const vec10d *v, float *x, float *y, float *z, float *w,
float *m, float *n, float *o, float *p, float *r, float *s)
{
assert ( v != 0 );
assert ( x != 0 );
assert ( y != 0 );
assert ( z != 0 );
assert ( w != 0 );
assert ( m != 0 );
assert ( n != 0 );
assert ( o != 0 );
assert ( p != 0 );
assert ( r != 0 );
assert ( s != 0 );
assert( v10d_isValid(v) != g_false );
*x = v->x;
*y = v->y;
*z = v->z;
*w = v->w;
*m = v->m;
*n = v->n;
*o = v->o;
*p = v->p;
*r = v->r;
*s = v->s;
}
Сие чудо нарыл на просторах интернетов. Для ценителей весь исходник http://pastebin.org/114060 .. Очевидно чуваки писали очередной Crysis :)
+55.3
#include<iostream>
#include<math.h>
//#include<csdio>
using namespace std;
void main(){
//char*s1=new char[0]
int i=0;
do
char*s1=new char[0];
cout<<'write s1: ';
cin>>s1[i];
i=i+1;
while (*s1[i]=="\0");
for(int j=1, j==i, j++)
cout<<s1[j];
cout<<endl;
delete []s1;
}
Вот такую поделку мне прислали на проверку с жалобой "не работает".
+55.3
#define constuserColor "usercolor"
#define consttagColor "tagcolor"
#define constmsgColor "idcolor"
#define constQcolor "quotecolor"
#define constLcolor "linkcolor"
#define constUbold "userbold"
#define constTbold "tagbold"
#define constMbold "idbold"
#define constQbold "quotebold"
#define constLbold "linkbold"
#define constUitalic "useritalic"
#define constTitalic "tagitalic"
#define constMitalic "iditalic"
#define constQitalic "quoteitalic"
#define constLitalic "linkitalic"
#define constUunderline "userunderline"
#define constTunderline "tagunderline"
#define constMunderline "idunderline"
#define constQunderline "quoteunderline"
#define constLunderline "linkunderline"
#define constIdAsResource "idAsResource"
#define constShowPhoto "showphoto"
#define constShowAvatars "showavatars"
#define constWorkInGroupchat "workingroupchat"
#define constVersion "0.9.9"
class JuickPlugin : public QObject, public PsiPlugin, public EventFilter, public OptionAccessor, public ActiveTabAccessor,
public StanzaFilter, public ApplicationInfoAccessor
{
Q_OBJECT
Q_INTERFACES(PsiPlugin EventFilter OptionAccessor ActiveTabAccessor StanzaFilter ApplicationInfoAccessor)
public:
JuickPlugin();
virtual QString name() const;
virtual QString shortName() const;
virtual QString version() const;
virtual QWidget* options();
virtual bool enable();
virtual bool disable();
virtual void applyOptions();
virtual void restoreOptions();
virtual bool processEvent(int account, QDomElement& e);
virtual bool processMessage(int account, const QString& fromJid, const QString& body, const QString& subject);
// OptionAccessor
virtual void setOptionAccessingHost(OptionAccessingHost* host);
virtual void optionChanged(const QString& option);
//ActiveTabAccessor
virtual void setActiveTabAccessingHost(ActiveTabAccessingHost* host);
//ApplicationInfoAccessor
virtual void setApplicationInfoAccessingHost(ApplicationInfoAccessingHost* host);
virtual bool incomingStanza(int account, const QDomElement& stanza);
void elementFromString(QDomElement& body,QDomDocument e, QString& msg, QString jid, QString resource = "");
void nl2br(QDomElement& body,QDomDocument e, QString msg);
void addPlus(QDomElement& body,QDomDocument e, QString msg, QString jid, QString resource = "");
void addSubscribe(QDomElement& body,QDomDocument e, QString msg, QString jid, QString resource = "");
void addHttpLink(QDomElement& body,QDomDocument e, QString msg);
void addTagLink(QDomElement& body,QDomDocument e, QString tag, QString jid);
void addUserLink(QDomElement& body,QDomDocument e, QString nick, QString altText, QString pattern, QString jid);
void addMessageId(QDomElement& body,QDomDocument e, QString mId, QString altText,QString pattern, QString jid, QString resource = "");
void addUnsubscribe(QDomElement& body,QDomDocument e, QString msg, QString jid, QString resource = "");
void addDelete(QDomElement& body,QDomDocument e, QString msg, QString jid, QString resource = "");
void addFavorite(QDomElement& body,QDomDocument e, QString msg, QString jid, QString resource = "");
Краткость - сестра таланта... Только видимо авторы этого чуда эту пословицу не знают.
Да и количество непонятных макросов нам тоже намекает.
Ну и конечно же необходимость в таком страшном множественном наследовании с возможностью рандомных побочных эффектов тоже намекает нам о говноархитектуре. В общем не зря авторы Psi решили начать писать новый клиент.
+55
bool validateIp(std::string& ip) {
if( ip.length() == 0 ) {
return false;
}
if( ip[0] == '.' ) {
return false;
}
// Проверка на наличие 3 точек
int cp = 0;
for( int i = 0; i < ip.length(); i++ ) {
if( ip[i] == '.' ) {
cp++;
}
}
if( cp != 3 ) {
std::cout << "проверка на 3 точки" << std::endl;
return false;
}
//=====================
// Проверка на 2 точки подряд
for( int i = 0; i < ip.length()-1; i++ ) {
if( ip[i] == '.' && ip[i+1] == '.' ) {
std::cout << "проверка на 2 точки подряд" << std::endl;
return false;
}
}
//===========================
//Проверка на больше 3 цифр подряд
int i = 0;
int j = 0;
for( i = 0; i < ip.length(); i++ ) {
for( j = i; j < i+4 && j < ip.length(); j++ ) {
if( j == i+3 && ip[j] != '.' ) {
std::cout << "проверка на 4 цифры подряд" << std::endl;
return false;
}
if( ip[j] == '.' ) {
i = j;
break;
}
}
}
return true;
//============================
}
Валидация IP-адреса