- 1
- 2
- 3
Bool IsNumber (string str) {
return (str.Replace ("0", "").Replace ("1", "").Replace ("2", "").Replace ("3", "").Replace ("4", "").Replace ("5", "").Replace ("6", "").Replace ("7", "").Replace ("8", "").Replace ("9", "").Length == 0);
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+153
Bool IsNumber (string str) {
return (str.Replace ("0", "").Replace ("1", "").Replace ("2", "").Replace ("3", "").Replace ("4", "").Replace ("5", "").Replace ("6", "").Replace ("7", "").Replace ("8", "").Replace ("9", "").Length == 0);
}
Где-то находил. Вроде это на Java
+140.5
#include <numeric>
#include <algorithm>
#include <iostream>
#include <functional>
#include <boost/iterator/counting_iterator.hpp>
int main()
{
std::cout << std::accumulate(boost::make_counting_iterator(2), boost::make_counting_iterator(8), 1, std::multiplies<int>());
return 0;
}
+153.8
for($i=0;$i<10;$i++){
$tf2[rand(0,count($tf2)-1)][2]-=$tf1[rand(0,count($tf1)-1)][1];
$tf1[rand(0,count($tf1)-1)][2]-=$tf2[rand(0,count($tf2)-1)][1];
}
Долго не мог понять, что этот кусок делает.
+157.7
{?$i=0;}
{foreach from=explode(',',$item.tags) item="tag"}
<a href="/{_ LANG}/tv,translations?tag={$tag|escape}">{$tag|escape}</a>{if $i < (count(explode(',',$item.tags)) - 1)}, {/if}
{?$i++}
{/}
No comments.
+108.6
void init()
{
int i;
for(i=0;i<4;i++)
ALG_RxConst[i] = -1;
for(i=0;i<4;i++)
ALG_TxConst[i] = -1;
for(i=0;i<4;i++)
ALG_EqInfo[i][0] = 0;
for(i=0;i<4;i++)
ALG_EqInfo[i][1] = -1;
for(i=0;i<4;i++)
ALG_EqInfo[i][2] = -1;
}
Индусу очень-очень нравится for ;)
+151
<...>
switch($action) {
case 'postAjouterDocument' :
$titre = read_post_str('text1');
$files['fichier'] = isset($_FILES['text2'])?$_FILES['text2']:'';
$codeRet = $ClsDocument->Add(GUSERID, $files, $titre, GROUPE );
location(PAGE_DOC_DEFAUT."&codeRet=".$codeRet);
exit();
break;
case 'postAjouterCommentaire' :
<...>
exit();
break;
case 'postModifierCommentaire' :
<...>
exit();
break;
}
зачем break; после exit(); ?
+176.4
if ('yes'!= 'yes') {
checkCaptcha();
return true;
}
в кодах блог движка нашел подобное..
+153
function db_encode_blob($data) {
return $data;
}
Drupal
−13
string emptyString = "";
int? emptyInt = 0;
−421.8
def myint2str(x, n):
zzeros = '0'
input_string = str(x)
string_len = len(input_string)
for zz in range(1,n-string_len,1):
zzeros = zzeros + '0'
rres = zzeros+str(x)
return rres
Задача: написать функцию которая переводит целое число в строку определённого размера, содержащую это целое число и нули.
То есть:
5 >> 00005
123 >> 00123
Отсюда: http://koldunov.net/?p=194