-
+41
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
int sheeps(int pole[10][10])
{
int i,j,f,k,r;
int rand_chislo, rand_chislo1, ts,s;
srand(time(NULL));
for (i=0;i<10;i++)
for (j=0;j<10;j++)
pole [i][j]=0;
do{ f=0;
rand_chislo = 0 + rand() %10;
rand_chislo1= 0 + rand() %10;
ts = 1+rand()%4;
if (ts==1) {for(i=0;i<3;i++) if(rand_chislo==i)f=1;}
if (ts==2) {for(i=7;i<10;i++) if(rand_chislo==i)f=1;}
if (ts==3) {for(i=0;i<3;i++) if(rand_chislo1==i)f=1;}
if (ts==4) {for(i=7;i<10;i++) if(rand_chislo1==i)f=1;}
}
while (f==1);
switch (ts){
case 1: pole[rand_chislo][rand_chislo1]=1; pole[rand_chislo-1][rand_chislo1]=1;
pole[rand_chislo-2][rand_chislo1]=1;pole[rand_chislo-3][rand_chislo1]=1; break;
case 2: pole[rand_chislo][rand_chislo1]=1; pole[rand_chislo+1][rand_chislo1]=1;
pole[rand_chislo+2][rand_chislo1]=1;pole[rand_chislo+3][rand_chislo1]=1; break;
case 3: pole[rand_chislo][rand_chislo1]=1; pole[rand_chislo][rand_chislo1-1]=1;
pole[rand_chislo][rand_chislo1-2]=1;pole[rand_chislo][rand_chislo1-3]=1;break;
case 4: pole[rand_chislo][rand_chislo1]=1; pole[rand_chislo][rand_chislo1+1]=1;
pole[rand_chislo][rand_chislo1+2]=1;pole[rand_chislo][rand_chislo1+3]=1; break; }
for (k=0;k<3;k++)
{
do{ f=0;
rand_chislo = 0 + rand() %10;
rand_chislo1= 0 + rand() %10;
ts = 1+rand()%4;
if (ts==1) {if(rand_chislo!=0){ for (i=rand_chislo-2;i<rand_chislo+2;i++)
for (j=rand_chislo1-1;j<=rand_chislo1+1;j++)
{if (pole[i][j]!=0){f=1;}}}else f=1; }
if (ts==2) {if (rand_chislo!=9) { for (i=rand_chislo-1;i<=rand_chislo+2;i++)
for (j=rand_chislo1-1;j<=rand_chislo1+1;j++)
{ if (pole[i][j]!=0){ f=1;}}}else f=1; }
if (ts==3) { if (rand_chislo1!=0) { for (i=rand_chislo-1;i<=rand_chislo+1;i++)
for (j=rand_chislo1-2;j<=rand_chislo1+1;j++)
{ if (pole[i][j]!=0){ f=1;}}}else f=1; }
if (ts==4) { if (rand_chislo1!=9) { for (i=rand_chislo-1;i<=rand_chislo+1;i++)
for (j=rand_chislo1-1;j<=rand_chislo1+2;j++)
{ if (pole[i][j]!=0){ f=1;}}}
else f=1; }
}
while (f==1);
switch (ts){
case 1: pole[rand_chislo][rand_chislo1]=1; pole[rand_chislo-1][rand_chislo1]=1; break;
case 2: pole[rand_chislo][rand_chislo1]=1; pole[rand_chislo+1][rand_chislo1]=1; break;
case 3: pole[rand_chislo][rand_chislo1]=1; pole[rand_chislo][rand_chislo1-1]=1;break;
case 4: pole[rand_chislo][rand_chislo1]=1; pole[rand_chislo][rand_chislo1+1]=1; break; }
}
for (k=0;k<2;k++)
{
do{ f=0;
rand_chislo = 0 + rand() %10;
rand_chislo1= 0 + rand() %10;
/*зесь еще 2 таких же while (if==1) и for k<3 и k<4 */
return pole[10][10];
}
курсовик первокурсника "морской бой". функция расстановки кораблей
equilibrium,
17 Сентября 2012
-
+137
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
{- Haskell -}
bruteforceGeneratorWithEasySimplication :: Description d => d -> [StandartTable]
bruteforceGeneratorWithEasySimplication description =
let width = size_h description; height = size_v description; vHeader = headerV description in
do
table <- genListBasedOn (map lineVariants vHeader)
return (ST table)
where
lineVariants :: [Int] -> [[Bool]]
lineVariants headerLine = let
всё_я_задолбался_однако = True -- K.O.
количество_цельных_блоков = length headerLine
число_промежутков = количество_цельных_блоков - 1
число_свободных_пробелов_которые_нам_нужно_распихать_между_цельными_блоками = ширина_поля - суммарная_длина_цельных_блоков
ширина_поля = size_h description
суммарная_длина_цельных_блоков = sum headerLine
возможная_строка_использующая :: [Int] -> [Bool]
возможная_строка_использующая разбиение = replicate (head разбиение) False ++
concat (zipWith (\x y -> replicate y True ++ replicate x False) (tail разбиение) headerLine)
и = and
по = undefined
in do
разбиение <- получить_разбиение_для_строки по (число_свободных_пробелов_которые_нам_нужно_распихать_между_цельными_блоками) и (число_промежутков)
return (возможная_строка_использующая разбиение :: [Bool])
получить_разбиение_для_строки по числу_свободных_элементов и числу_промежутков = do ...
Из раннего.
По-видимому, задолбался писать на тарабарщине, захотелось выражаться родными русскими словами.
Jean-Esther,
16 Сентября 2012
-
+156
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
@show[]
$cars[^table::sql{select * from count_cars order by sortir}]
<script>
var CarsDescription = new Array()^;
$counter(1)
^cars.menu{
CarsDescription[$counter] = '$cars.characteristic'^;
^counter.inc[]
}
</script>
<script type="text/javascript" src="/cars_calc/script.js"></script>
<link rel="stylesheet" type="text/css" href="/cars_calc/style.css">
<section class="page">
<section class="scheme">
<span id="cr" class="cr"></span>
$cars_count(16)
^for[car](1;$cars_count){
<span id="select-car-$carId" class="car-$carId">$car</span>
}
</section>
Код из одной веб-студии. Смысл в том что в javascript должен быть передан массив из базы данных, вместо того чтобы послать пакет с нужными данными в формате json (или любом другом) и обработать его, в исходный файл html-разметки (тут как видно и javascript вставлен) добавили код Parser'а (для тех кто-незнаком это язык для быстрой разработки веб-сайтов от Лебедева, что-то вроде простой альтернативы php), который перед тем как отдать пользователю страницу, обрабатывает её и вставляет в нужные места, нужные данные. В общем сами оценивайте этот маразм...
Kerny,
16 Сентября 2012
-
+11
- 1
clEnqueueReleaseGLObjects(queue, objects.size(), objects.data(), 9, NULL, NULL);
В целом ничего страшного, но почему на клавиатуре девятка так рядом с нулём?
bazhenovc,
15 Сентября 2012
-
+114
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
#include <stdio.h>
/* Программа выводит ASCII-коды введённых символов */
int main()
{
int a[255];
int i;
for (i = 0; i < 256; i++) {
a[i] = i;
}
int c;
while ((c = getchar()) != EOF) {
if (c != '\n')
printf("%d\n", a[c]);
}
return 0;
}
vistefan,
15 Сентября 2012
-
+132
- 1
- 2
- 3
- 4
<form method="POST" action="/registr/detail.php?ID=114022261">
<input type="submit" value="Да" name="YES">
<input type="submit" value="Нет" name="NO">
</form>
Таким образом на mkrf.ru посетитель подтвердить своё желание продолжить просмотр каждый раз, когда хочет почитать карточку фильма "с ограничениями".
nsauk,
15 Сентября 2012
-
+43
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
<?php
function monthName($monthNumber) {
echo date('F', strtotime('first day of '.($monthNumber - date('n')).' month'));
}
monthName(10);
?>
Знаю, что не говнокод, но решил запостить - поделиться, ибо встречал тут много говнокода относительно подобного алгоритма получения названия месяца по порядковому номеру онного и много различных вариантов "неговнокода" в коментариях, но именно такой "пыхдатой" реализации не видел - впечатлило, хороший "антиВелосипед" :)
killro0000,
15 Сентября 2012
-
−105
- 1
- 2
- 3
- 4
- 5
if [ `which which` ]; then
...
else
...
fi
gongled,
14 Сентября 2012
-
+41
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
function sqldate2time($date) {
list($y, $m, $d) = explode('-', $date);
$res = mktime(3,0,0,$m,$d,$y);
return($res);
}//function
//Добавляем к дате указанное кол-во дней
function add_days($date, $days = 1) {
$t = sqldate2time($date);
$t += (86400*$days);
return(date('Y-m-d', $t));
}//function
Попытка на каком-то форуме, прибавить интервал времени (к примеру 7 дней)
nepster,
14 Сентября 2012
-
−86
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
switch(page) {
case 0:
showCurrentCar(page);
hidePreviousCar(currentModel);
currentModel = page;
break;
case 1:
showCurrentCar(page);
hidePreviousCar(currentModel);
currentModel = page;
break;
case 2:
showCurrentCar(page);
hidePreviousCar(currentModel);
currentModel = page;
break;
case 3:
showCurrentCar(page);
hidePreviousCar(currentModel);
currentModel = page;
break;
}
Долго искал отличия кейсов, не нашол
Edd,
14 Сентября 2012