-
+145.5
- 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
#include <iostream>
#include <locale.h>
//------------------------------------------------------------------
// The PREVED Language Kernel area. Do not touch!
#if !defined (_MSC_VER) || _MSC_VER < 1400
#error Wrong compiler! Use MSVS 8.0
#endif
#define НАЧЕЛ {
#define КОНЧЕЛ ;}
#define ТИПА int
#define ВДРУГ if (
#define ТАДА )
#define НИХРИНА else
#define ВЗАД return
#define КАГДИЛА (
#define ЙО ;
#define ЖЖОШ(p,n) for (; (p) <= (n); (p)++)
#define БАЗАР std::cout <<
#define СЛЫШЬ <<
#define СТОЙ system ("echo. & pause");
#define БЛИН _wsetlocale (LC_ALL, L"Russian_Russia.ACP");
#define ВРОДЕ try
#define ИБАНУЦЦО throw
#define АПСТЕНУ catch (const char* __чё__)
#define ПРЕВЕД ТИПА main КАГДИЛА ТАДА
#define МЕДВЕД ВЗАД 0; КОНЧЕЛ
// End of area
//------------------------------------------------------------------
ТИПА КРУТО КАГДИЛА ТИПА фигня ТАДА
НАЧЕЛ
БАЗАР "ВАЩЕ " ЙО
ВДРУГ фигня == 8 ТАДА ИБАНУЦЦО "мля! " ЙО
ВЗАД 0
КОНЧЕЛ
ПРЕВЕД
НАЧЕЛ
БЛИН
ВРОДЕ НАЧЕЛ
ТИПА фишка = 0 ЙО
ЖЖОШ (фишка, 10)
НАЧЕЛ
БАЗАР фишка СЛЫШЬ " ";
ВДРУГ фишка >= 5 ТАДА КРУТО (фишка) ЙО
КОНЧЕЛ
КОНЧЕЛ АПСТЕНУ НАЧЕЛ
БАЗАР "ИБАНУЦЦО invoked: " СЛЫШЬ __чё__;
КОНЧЕЛ
СТОЙ
МЕДВЕД
стащил с форума, наверное - боян=)
Novi4oK,
21 Января 2010
-
+50.4
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
map<string, int> M;
...
M["one"] = 1;
M["two"] = 2;
M["google"] = 1e100;
...
// найдём сумму всех значений --- т.е. всех правых частей
// пар <string, int>
int r = 0;
tr(M, it) {
r += it->second;
// (*it).first == [string], (*it).second == [int]
}
и это на сайте обучения программирования!!!
http://informatics.mccme.ru/moodle/mod/book/view.php?id=492&chapterid=216
Novi4oK,
21 Января 2010
-
+77.3
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
protected static Map<Long, List<Bank.BankMoney>> getWinnersBanksMap(Map<Long, List<Bank.BankMoney>> sharedBank) {
Map<Long,List<Bank.BankMoney>> winnersWithBanks = new HashMap<Long, List<Bank.BankMoney>>();
for (Map.Entry<Long, List<Bank.BankMoney>> longListEntry : sharedBank.entrySet()) {
Long playerId = longListEntry.getKey();
List<Bank.BankMoney> banksWonOnThisIteration = longListEntry.getValue();
List<Bank.BankMoney> banks1 = winnersWithBanks.get(playerId);
if (banks1 == null) {
banks1 = new ArrayList<Bank.BankMoney>();
winnersWithBanks.put(playerId, banks1);
}
banks1.addAll(banksWonOnThisIteration);
}
return winnersWithBanks;
}
В результате серии рефакторингов чужого кода обнаружил следующий метод, над которым долго ломал голову - что он делает... Оказалось, ничего. Возвращает копию исходного объекта.
dvb,
21 Января 2010
-
+70.8
- 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
lseek( h, headerSize+0x500, SEEK_SET );
if( _read( h, &buf, sizeof buf ) != sizeof buf )
goto __read_error;
for( int i = 0; i < NUM_EL(sig); ++i ) {
if( *(long*)&buf[sig->offs] != *(long*)sig->str ) {
__wrong_format:
message( .... );
_close( h );
return FALSE;
}
}
if( *(long*)&buf[0x2C] != *(long*)"_TAG" ) {
message( .... );
_close( h );
return FALSE;
}
if( *(long*)&buf[0x32] != *(long*)"_VER" )
goto __wrong_format;
*platform = *(ushort*)&buf[0x30];
if( ver ) {
long verOffs = headerSize + ((ulong)(*(ushort*)&buf[0x38]) << 4) + *(ushort*)&buf[0x36];
lseek( h, verOffs, SEEK_SET );
if( _read( h, ver, sizeof(float) ) != sizeof(float) )
goto __read_error;
}
_close( h );
Нужно было посмотреть, как делается одна вещь, залез в исходники некоторого старого __С++__(!!!!!!!!!!!!!!)(так что не надо "где здесь с++"=) ) проекта, там классы и все, как положено =)
Причем писал не школьник, а взрослый дядька, у которого опыта больше, чем у меня сознательной жизни(ну это я образно=) ) Я до сих пор пребываю в состоянии культурно-эстетического шока =)
ISith,
21 Января 2010
-
+65.1
- 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
#include <iostream>
#include <math.h>
using namespace std;
double absolute( double x ) {
return (( x >= 0.0 ) ? x : x*(-1) );
}
double get_cof( double time ) {
if( time ==1 ) return 1;
double rettime = ( time + 1 ) / time;
return rettime;
}
double get_disnow( double time, double speed ) {
double disnow = get_cof( time ) * speed;
return disnow;
}
double get_distance( double time, double speed ) {
if( time ==1 ) return 20;
double distance = get_disnow( time, speed );
return distance;
}
using namespace std;
int main( int argc, char **argv ) {
double x = 0.0;
for( double t = 1.0; t < 10000 ;t+=1 )
{
x += get_distance( t, 10.0 );
x *= get_cof( t );
if( (absolute( x - (t * 100 ) ) < 5) || t == 6480 )
{
cout << " hallelua time = " << t << endl;
cout << " Moskitos = " << x << " cm; ";
cout << ", Man = " << t * 100 << " cm; " << endl;
}
}
return 0;
}
Даже не знаю, что здесь самое интересное. Просто прочитайте.
Abrosov,
21 Января 2010
-
+138.7
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
char serverName[MAX_NAME];
char buttonName[MAX_NAME];
char serverIdStr[3];
serverIdStr[2] = '\0';
int currentSpot = 0;
// ...... получение serverName и currentSpot
serverIdStr[0] = '0' + ((currentSpot+1)/10);
serverIdStr[1] = '0' + ((currentSpot+1)%10);
strcpy(buttonName, buttonPrefix);
strcat(buttonName, serverIdStr);
Кто то не знает про существование sprintf...
pushkoff,
20 Января 2010
-
+129.4
- 1
- 2
- 3
<a class="btn" href="#" onclick="{if $client->getId()}xmlrpc_choose_playlist(this,{$mp3->getId()},1,'top_month_mp3');return false;{else}xmlrpc_load_popup('login', null);{/if}">
<img src="views/default/images/add.gif" width="8" height="8" alt="Добавить в плейлист" title="Добавить в плейлист" />
</a>
Это кусок смартявского шаблона
Типа песенку в плейлист добавляем
а иногда таких песен на странице ни одна сотня )))
paranoid,
20 Января 2010
-
+144.8
- 1
- 2
- 3
- 4
$("a.set_mark_link",$(".new_email_form").parents(".sub_chapter")).css("background-color","#f00");
$("a.set_mark_link",$(".new_email_form").parents(".sub_chapter")).bind("click",mark_email);
$("a.set_mark_link",$(".new_email_form").parents(".sub_chapter")).live("click",mark_email);
Интерестно, почему первые две конструкции работают, а последняя - нет?
SilentImp,
20 Января 2010
-
+137.7
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
if (e.Source.GetType().Name.ToString()=="Square")
{
if (((Square)e.Source).Background == SystemColors.ControlBrush)
{
if ((((Square)e.Source).Content.Equals("")))
{
((Square)e.Source).Background = Brushes.Blue;
}
}
else
{
if (((Square)e.Source).Background != Brushes.White)
if (((Square)e.Source).Background != Brushes.Red)
if (((Square)e.Source).Background != Brushes.Green)
((Square)e.Source).Background = SystemColors.ControlBrush;
}
}
poacher,
20 Января 2010
-
−113.6
- 1
- 2
- 3
- 4
sub append {
my $appendstring = @_[0];
$returnstring = "$returnstring$appendstring";
}
Из плагина к nagios'у, который проверяет состояние интерфейсов на cisco-девайсах. http://svn.opsview.org/opsview/trunk/opsview-core/nagios-plugins/check_snmp_cisco_ifstatus .
aag,
20 Января 2010