- 1
- 2
- 3
fib 1 = 1
fib 2 = 1
fib n = fib(n-1) + fib (n-2)
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+133
fib 1 = 1
fib 2 = 1
fib n = fib(n-1) + fib (n-2)
Хаскель это вам не математика, тут надо и вычислительную сложность учитывать.
+166
#include <dir.h>//ДЛЯ ОПРЕДЕЛЕНИЯ mkdir(ИМЯ ПАПКИ)
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <alloc.h>
#include <string.h>
#include <iostream.h>
int ndig(char x)
{if('0'<=x&&x<='9')return 0;else return 1;}
// СТРОКА ВЕДОМОСТИ ДЛЯ ОДНОГО СТУДЕНТА
struct stud
{char fio[122];int b[9],ns
static int nc
,nd;
void out(FILE*fo);stud(){fio[121]=0;}
stud(FILE*fi);
stud(stud&s){*this=s;}
}; //end of stud body
int stud::nc=44;
int stud::nd=5;
stud::stud(FILE *fi)
{fscanf(fi,"%i ",&ns); fgets(fio,nc,fi);
for(int j=1;j<=nd;++j)fscanf(fi,"%i",&b[j]);}
void stud::out(FILE*fo=stdout)
{fprintf(fo,"%3i ",ns);
fputs(fio,fo); for(int j=1;j<=nd;++j)
{if(b[j]>=0&&b[j]<6) fprintf(fo,"%3i",b[j]);
else fprintf(fo," ");}
fprintf(fo,"\n"); if ( fo==stdout) getch();
}//end of stud
//ВЕДОМОСТЬ ОДНОЙ ГРУППЫ
//("МАССИВ СТРОК" ДЛЯ ОТДЕЛЬНЫХ СТУДЕНТОВ)
struct grup{ stud**st;//"МАССИВ СТУДЕНТОВ"
FILE*fi;char title[3][122]//"ШАПКА" ВЕДОМОСТИ
,sf[77];
int ms;//ЧИСЛО СТУДЕНТОВ
void nw();//ПАМЯТЬ ДЛЯ СТУДЕНТОВ
void out(char*sf); void out(FILE*fo);
grup(grup&g);grup(int fms){ms=fms; nw();}
grup(char*sf); grup&operator=(const grup&g);
void deg();~grup(){deg();} grup(); };
//end of grup body
grup::grup(){ms=0;st=0;fi=0;
for(int j=0;j<3;++j)memset(title[j],0,122);}
void grup::nw()
{st=new stud*[ms+1];
if(!st){cout<<"\nst=0 grup::nw()\n";exit(1);}
for(int j=0;j<=ms;++j)
{st[j]=new stud;
if(!st){cout<<"\nst[j]=0\n";exit(1);}
}}
grup::grup(char*fsf)
{strcpy(sf,fsf); char s[77]="\n"; int j;
fi=fopen(sf,"rt");
if(!fi)
{cout<<"\n0)fi=0,sf="<<sf;getch();exit(1);}
ms=0; while(!feof(fi)){fgets(s,77,fi);++ms;}
ms-=3; fclose(fi); fi=fopen(sf,"rt");
if(!fi){cout<<"\nfi\n";exit(1);}
for(j=0;j<3;++j) fgets((title[j]),77,fi);
//ВВОД "СТУДЕНТОВ" ИЗ ФАЙЛА sf
nw();for(j=1;j<=ms;++j){stud stj(fi);*st[j]=stj;}
fclose(fi);
}
grup&grup::operator=(const grup&g)
{if(this==&g)return*this; int j; this->deg();
fi=g.fi; strcpy(sf,g.sf); ms=g.ms;
nw(); for(j=0;j<=ms;++j)*st[j]=*g.st[j];
for(j=0;j<3;++j)strcpy(title[j],g.title[j]);
return*this;
}
grup::grup(grup&g)
{for(int j=0;j<3;++j)strcpy(title[j],g.title[j]);
ms=g.ms; strcpy(sf,g.sf);
nw(); for(j=0;j<=ms;++j)*st[j]=*g.st[j];
}
void grup::deg()
{if(st) {for(int j=0;j<=ms;++j)
if(st[j]){delete st[j];st[j]=0;}delete[]st;st=0;}
}
void grup::out(FILE*fo=stdout)
{if(fo==stdout)cout<<'\n'; int j=0;
for(;j<3;j++) fputs(title[j],fo);
for(j=1;j<=ms;j++) st[j]->out(fo);
}
void grup::out(char*sf)
{FILE*fo=fopen(sf,"wt");
if(!fo){cout<<"\nfo=0\n";exit(1);}
out(fo); fclose(fo);
} //end of grup
Кусок кода с "базовыми классами" для курсовой работы в непоследнем университете Петербурга. Данные "классы" потом по заданию предлагается всячески расширять.
А потом жалуемся, что студенты ничего не умеют. А кто ж их учит?
+129
temp = (NODE *)malloc(sizeof(NODE));
if (temp == NULL)
{
Free(temp);
Free(task);
return NULL;
}
Курсовик ночью по пьяни. Подстраховался блин.
+124
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*-
;;; Copyright (C) 2011, Dmitry Ignatiev <[email protected]>
;;; Permission is hereby granted, free of charge, to any person
;;; obtaining a copy of this software and associated documentation
;;; files (the "Software"), to deal in the Software without
;;; restriction, including without limitation the rights to use, copy,
;;; modify, merge, publish, distribute, sublicense, and/or sell copies
;;; of the Software, and to permit persons to whom the Software is
;;; furnished to do so, subject to the following conditions:
;;; The above copyright notice and this permission notice shall be
;;; included in all copies or substantial portions of the Software.
;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
;;; DEALINGS IN THE SOFTWARE
(in-package #:neural-flow)
;; Stolen from `trivial-garbage'
#+openmcl
(defvar *weak-pointers* (cl:make-hash-table :test 'eq :weak :value))
#+(or allegro openmcl lispworks)
(defstruct (weak-pointer (:constructor %make-weak-pointer))
#-openmcl pointer)
(declaim (inline make-weak-pointer))
(defun make-weak-pointer (object)
#+sbcl (sb-ext:make-weak-pointer object)
#+(or cmu scl) (ext:make-weak-pointer object)
#+clisp (ext:make-weak-pointer object)
#+ecl (ext:make-weak-pointer object)
#+allegro
(let ((wv (excl:weak-vector 1)))
(setf (svref wv 0) object)
(%make-weak-pointer :pointer wv))
#+openmcl
(let ((wp (%make-weak-pointer)))
(setf (gethash wp *weak-pointers*) object)
wp)
#+corman (ccl:make-weak-pointer object)
#+lispworks
(let ((array (make-array 1)))
(hcl:set-array-weak array t)
(setf (svref array 0) object)
(%make-weak-pointer :pointer array)))
(declaim (inline weak-pointer-value))
(defun weak-pointer-value (weak-pointer)
"If WEAK-POINTER is valid, returns its value. Otherwise, returns NIL."
#+sbcl (values (sb-ext:weak-pointer-value weak-pointer))
#+(or cmu scl) (values (ext:weak-pointer-value weak-pointer))
#+clisp (values (ext:weak-pointer-value weak-pointer))
#+ecl (values (ext:weak-pointer-value weak-pointer))
#+allegro (svref (weak-pointer-pointer weak-pointer) 0)
#+openmcl (values (gethash weak-pointer *weak-pointers*))
#+corman (ccl:weak-pointer-obj weak-pointer)
#+lispworks (svref (weak-pointer-pointer weak-pointer) 0))
;;Red-black tree
(declaim (inline %node %nleft %nright %nparent %nred %ndata %ncode
(setf %nleft) (setf %nright) (setf %nparent)
(setf %nred) (setf %ndata) (setf %ncode)))
(defstruct (%node (:constructor %node (data code parent red))
(:conc-name %n))
(left nil :type (or null %node))
(right nil :type (or null %node))
(parent nil :type (or null %node))
(red nil)
data
(code 0 :type (integer 0 #.most-positive-fixnum)))
(declaim (inline %tree %tree-root (setf %tree-root)))
(defstruct (%tree (:constructor %tree ())
(:copier %copy-tree))
(root nil :type (or null %node)))
(declaim (inline rotate-left))
(defun %rotate-left (tree node)
(declare (type %tree tree) (type %node node)
(optimize (speed 3) (safety 0)))
(let ((right (%nright node)))
(when (setf (%nright node) (%nleft right))
(setf (%nparent (%nleft right)) node))
(if (setf (%nparent right) (%nparent node))
(if (eq node (%nleft (%nparent node)))
(setf (%nleft (%nparent node)) right)
(setf (%nright (%nparent node)) right))
(setf (%tree-root tree) right))
Вылезли глаза! Как на этом можно писать?
+161
// START MY FOR MENU
$list_pages = preg_replace('/<li([^>]*)>/is', ' ', $output);
$list_pages = str_replace('</li>', '', $list_pages);
$list_pages = preg_replace('/<a/is', '</td><td class="menu"> <a$1', $list_pages);
if (isset($_GET['page_id']) AND !is_numeric($_GET['page_id'])) { exit("ERROR!"); }
$pd = mysql_real_escape_string($_GET['page_id']);
if(strstr($_SERVER['REQUEST_URI'], 'page_id='.$pd) == TRUE) {
$list_pages = preg_replace('/<\/td><td class=\"menu\"\> <a href=\"(http:\/\/'.$_SERVER["HTTP_HOST"].'\/\?page_id='.$pd.')/is', '</td><td class="menu_click"><a href="$1', $list_pages);
}
for($i=0; $i<sizeof($pages); $i++) {
$link = $pages[$i]->guid;
$lol = '';
if(strstr($_SERVER['REQUEST_URI'], '?') == TRUE) {
if ($link == 'http://'.$_SERVER['HTTP_HOST'].'/?'.$_SERVER['QUERY_STRING']) {
$list_pages = preg_replace('/<\/td><td class=\"menu\"\> <a href=\"(http:\/\/'.$_SERVER["HTTP_HOST"].'\/\?'.$_SERVER["QUERY_STRING"].')/is', '</td><td class="menu_click2"><a href="$1', $list_pages);
}
} else {
if ($link == 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']) {
$list_pages = preg_replace('/<\/td><td class=\"menu\"\> <a href=\"(http:\/\/'.$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"].')/is', '</td><td class="menu_click2"><a href="$1', $list_pages);
}
}
}
$output = $list_pages;
$str = preg_split("/<\/a\>/i", $output);
$moar = '';
for ($i=0; $i<sizeof($pages); $i++)
{
$moar .= preg_replace('/<\/td><td class=\"menu\"\> <a href=\"(.*)\" title=\"(.*)\">/is',
'</td><td class="menu" onclick="linkgo(\'$1\');" id="moar'.$i.'" onmouseover="menu1(\'moar'.$i.'\');" onmouseout="menu2(\'moar'.$i.'\');"> <a href="$1" title="$2">', $str[$i]);
$moar .= "</a>";
}
$output = $moar;
// END MY FOR MENU
None ;)
+155
<?php
$url = $_GET['url'];
$url = str_replace('http://', '', $url);
echo '<a href="http://$url">123</a>';
?>
+145
public double FindMax(double num1, double num2, double num3)
{
double max = num1;
if (num2 > max)
{
max = num2;
}
if (num3 > max)
{
max = num3;
}
return max;
}
+161
width ? width-- : width;
height ? height-- : height;
Ахуй нехуевый. Не говнокод, наверно, но всё же.
0
from colorama import init, Fore, Back, Style
init()
print(Back.BLACK)
print(Fore.RED)
print(Style.NORMAL)
print("Script mamoeba/Скрипт сделан")
print("┌────────────────────────────────────┐")
print("│Author : GovnoCode user │")
print("│Github : https://:/│")
print("└────────────────────────────────────┘")
print("YouTube: utube")
print("▄▀▄ █▄░▄█ ▀ █▄░█ ▄▀▄ ▄▀▄ █▀▄ ▐▌░▐▌ █▀▄ ▄▀▄")
print("█▀█ █░█░█ █ █░▀█ █░█ █▀█ █░█ ░▀▄▀░ █▀█ █░█")
print("▀░▀ ▀░░░▀ ▀ ▀░░▀ ░▀░ ▀░▀ ▀▀░ ░░▀░░ ▀▀░ ░▀░")
print("Advertise Bot Amino")
lz = []
from concurrent.futures import ThreadPoolExecutor
import concurrent.futures
import amino
def advertise(data):
listusers = []
for userId in data.profile.userId:
listusers.append(userId)
return listusers
email = input("Email/Почта: ")
password = input("Password/Пароль: ")
msg = input("Message/Сообщение: ")
client = amino.Client()
client.login(email=email, password=password)
clients = client.sub_clients(start=0, size=1000)
for x, name in enumerate(clients.name, 1):
print(f"{x}.{name}")
communityid = clients.comId[int(input("Выберите сообщество/Select the community: "))-1]
sub_client = amino.SubClient(comId=communityid, profile=client.profile)
users = sub_client.get_online_users(size=1000)
user = advertise(users)
for i in lz:
if i in user:
user.remove(i)
print("Sending Advertise")
for _ in range(4000):
with concurrent.futures.ThreadPoolExecutor(max_workers=40000) as executor:
_ = [executor.submit(sub_client.start_chat, user, msg) for userId in user]
print("Sending Advertise 2")
for _ in range(4000):
with concurrent.futures.ThreadPoolExecutor(max_workers=40000) as executor:
−1
#include <iostream>
#include <string>
using namespace std;
struct A
{
uint16_t n;
uint8_t a1:1;
uint8_t a2:1;
uint8_t a3:1;
uint8_t a4:1;
uint8_t a5:4;
uint8_t b;
} __attribute__((packed));
int main()
{
char v[] = { 0x1, 0x1, 0b01010011, 0x9 };
A *p = (A*)v;
cout << (uint16_t)p->a1 << endl;
cout << (uint16_t)p->a2 << endl;
cout << (uint16_t)p->a3 << endl;
cout << (uint16_t)p->a4 << endl;
cout << (uint16_t)p->a5 << endl;
cout << (uint16_t)p->b << endl;
}
http://cpp.sh/6e5myf
Битовые поля неправильно считываются.