- 1
- 2
- 3
- 4
- 5
- 6
MyClass * obj = (MyClass*)true;
while (obj)
{
obj = GetObj();
// ...
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+166
MyClass * obj = (MyClass*)true;
while (obj)
{
obj = GetObj();
// ...
}
+137
function random return float is
variable X : float;
begin
return X;
end function random ;
Вот такую реализацию функции random посоветовали на одном VHDL форуме. :D
+911
TVector4 V0;
TVector4 V1;
TVector4 V2;
//....
//Пример компилирующегося допустимого использования:
(V0+V1)=V2;
Нашёл я тут мега библиотеку в инете для работы с векторами. За такое нужно бить по рукам.
+127.8
int main()
{
if (2 * 2 != 4)
{
printf ("Плохой день!");
getch();
return 1;
}
...
}
А вдруг???
+61.2
unsigned int nRecsSize=0;
nRecsSize+=4;
nRecsSize+=1;
nRecsSize+=1;
nRecsSize+=rec_.ip.length();
nRecsSize+=6;
BYTE *pData = new BYTE[nRecsSize];
Вот так надо высчитывать память под динамический массив
+138.8
#include <unistd.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
// grep ^\s*$ file1 file2 ... | wc -l
int main(int argc, const char **argv)
{
int fd[2];
pid_t pid;
assert(!pipe(fd));
assert((pid = fork()) >= 0);
if (!pid)
{
char **newargv;
assert(dup2(fd[1], 1) == 1);
assert(!close(fd[0]));
assert(!close(fd[1]));
assert(newargv = malloc((argc + 2) * sizeof(char *)));
newargv[0] = "grep";
newargv[1] = "^\\s*$";
memcpy(newargv + 2, argv + 1, (argc + 1) * sizeof(char *));
assert(execvp("grep", newargv) * 0);
}
assert((pid = fork()) >= 0);
if (!pid)
{
assert(dup2(fd[0], 0) == 0);
assert(!close(fd[0]));
assert(!close(fd[1]));
assert(execlp("wc", "wc", "-l", NULL) * 0);
}
assert(!close(fd[0]));
assert(!close(fd[1]));
while (wait(NULL) != -1);
return 0;
}
+200.8
$d=str_replace('-', '.', date("Y-m-d"));
Дата через точку )))
+144
List<Student> students = new List<Student>
{
new Student {LastName="Omelchenko", Scores= new List<int> {97, 72, 81, 60}},
new Student {LastName="O'Donnell", Scores= new List<int> {75, 84, 91, 39}},
new Student {LastName="Mortensen", Scores= new List<int> {88, 94, 65, 85}},
new Student {LastName="Garcia", Scores= new List<int> {97, 89, 85, 82}},
new Student {LastName="Beebe", Scores= new List<int> {35, 72, 91, 70}}
};
+143.8
using System;
class MyGenericClass<T> {
T ob;
public MyGenericClass(T o) {
ob = o;
}
public T getob() {
return ob;
}
public void showType() {
Console.WriteLine("Type of T is " + typeof(T));
}
}
public class Test {
public static void Main() {
MyGenericClass<int> iOb;
iOb = new MyGenericClass<int>(102);
iOb.showType();
int v = iOb.getob();
Console.WriteLine("value: " + v);
MyGenericClass<string> strOb = new MyGenericClass<string>("Generics add power.");
strOb.showType();
string str = strOb.getob();
Console.WriteLine("value: " + str);
}
}
как не надо юзать шаблоны классов
+163.5
$this->query_insert($this, array('', $mode, '', '',$id_group_new, $id_subgroup, $id_product,
'', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '', '', ''));
Вышел на этот кусок гкода с ошибки о неверном количестве значений в sql insert, не удивился :)