1. Си / Говнокод #15965

    +131

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    key_t cXxxYyyyZzz::getKey( char *pValue )
    {
      key_t key=INVALID_SEMKEY;
    
      if ( !pValue ) return key;
    
      for(int i=0; (char)0 != pValue[i]; ++i )
      {
        if ( 1==i && 'x' == tolower(pValue[1]) && '0' == pValue[0] )
          continue;
        if ( !isxdigit(pValue[i]) )
          return key;
      }
      return strtoul(pValue,(char**)0,16);
    }

    немецкий велосипед.

    Dummy00001, 12 Мая 2014

    Комментарии (0)
  2. Си / Говнокод #15944

    +133

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    #include <stdlib.h>
    #include <stdio.h>
    #include <string.h>
    #include <unistd.h>
    
    void my_char_plus(const void *a, const void *b, void *c)
    {
      char tmp =  (*(char*)a + *(char*)b);
      memcpy(c,(void*)(&tmp),sizeof(char));
    }
    
    void my_char_minus(const void *a, const void *b, void *c)
    {
      char tmp =  (*(char*)a - *(char*)b);
      memcpy(c,(void*)(&tmp),sizeof(char));
    }
    
    
    
    void operation(const void *funct(const void*,const void*,void*),
                          const void *a, const void *b, void *c )
    {
      funct(a,b,c);
    }
    
    char ret_last_arg(const void *funct(const void*,const void*,void*),
                          const void *a, const void *b)
    {
      char c;
      funct(a,b,(void*)&c);
      return c;
    }
    
    
    
    int main(void)
    {
    
      char a, b;
      a = 5; b = 7;
      
      
      void *plus = &my_char_plus; char c;
      operation(plus, (const void*)&a, (const void*)&b, (void*)&c);
      printf("5 + 7 = %i\n", c);
      
      
      void *minus = &my_char_minus;
      char d = ret_last_arg(minus, (const void*)&a, (const void*)&b);
      printf("5 - 7 = %i\n", d);
      
      
    // LISP LISP LISP
    #define LISP(ar,aa,bb) ret_last_arg(ar, (const void*)&(char){aa}, (const void*)&(char){bb} )
    
      char e = LISP(plus,2,LISP(plus,2,2));
      printf("(+ 2 (+ 2 2 ) ) = %i\n", e);
      
      return 0;
    }

    Лиспопрограммирование на сишке через макрос (префиксная запись)
    Только оно кривовато тут, т.е. получаем трехадресный код (не как в лиспе)
    http://masters.donntu.edu.ua/2006/fvti/svyezhentsev/library/article2.htm
    Можно делать интерпретаторы фигни всякой, шитый код. Я упорот короче

    j123123, 08 Мая 2014

    Комментарии (18)
  3. Си / Говнокод #15895

    +132

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    #include <stdio.h>
    
    unsigned int mid (unsigned int a, unsigned int b)
    {
    	if (a > b) {unsigned int c = a; a = b; b = c;}
    	for(; a < b; a--, b++) {;};
    	return a;
    }
    
    int main(void) {
    	printf("%u %u %u %u", mid(2,2), mid(3,2), mid(2,3), mid(3,3));
    	return 0;
    }

    Это я хочу найти середину. Где-то я туплю

    j123123, 04 Мая 2014

    Комментарии (27)
  4. Си / Говнокод #15872

    +154

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    if(sel.ToInt()==1){
      Form1->NumberOfIndexes = 1;
    }else if(sel.ToInt()==2){
      ...
      //еще 11 таких же кучек
      ...
    }else if(sel.ToInt()==13){
      Form1->NumberOfIndexes = 13;
    }else{
      Form1->NumberOfIndexes = 1;
    }

    dm-ua, 30 Апреля 2014

    Комментарии (25)
  5. Си / Говнокод #15871

    +134

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    try{
        tempPage1Int = tempPage1.ToInt();
      }catch(Exception &E){
        tempPage1Int = 0;
        goto NEXTFUCKER;
      }
      NEXTFUCKER:

    Дописываю из-под стола.

    dm-ua, 30 Апреля 2014

    Комментарии (6)
  6. Си / Говнокод #15870

    +132

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    if(fileCounter < 1000){
          subDir =  "SUBDIREC.001";
          //много кода
        }else if (fileCounter < 2000 && fileCounter > 999){
          subDir =  "SUBDIREC.002";
          //много кода, плюс еще 17 таких же веток
        }else if (fileCounter < 20000 && fileCounter > 18999){
          subDir =  "SUBDIREC.020";
          //много кода
        }

    dm-ua, 30 Апреля 2014

    Комментарии (5)
  7. Си / Говнокод #15867

    +134

    1. 1
    2. 2
    3. 3
    while(SLOBirthsISEX->Strings[p].Length() < 1){
        SLOBirthsISEX->Strings[p] = " " + SLOBirthsISEX->Strings[p];
      }

    нет слов

    dm-ua, 30 Апреля 2014

    Комментарии (8)
  8. Си / Говнокод #15843

    +127

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    #define PIXEL_PARTS_NUM 3
    
    typedef struct _pixel {
            char parts[PIXEL_PARTS_NUM];
    } pixel;

    evg_ever, 24 Апреля 2014

    Комментарии (21)
  9. Си / Говнокод #15828

    +133

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    ...
    int
    (mblen)(const char *s, size_t n)
    {
    	if (s == (const char *)NULL) return 0;	/* no state dependent codings */
    	if (n <= 0) return 0;
    	return (*s != 0);
    }
    ...
     int
    mbtowc(wchar_t *pwc, register const char *s, size_t n)
    {
    	if (s == (const char *)NULL) return 0;
    	if (n <= 0) return 0;
    	if (pwc) *pwc = *s;
    	return (*s != 0);
    }
    ...
     int
    wctomb(char *s, wchar_t wchar)
    {
    	if (!s) return 0;		/* no state dependent codings */
    
    	*s = wchar;
    	return 1;
    }

    THE AMSTERDAM COMPILER KIT V6.0pre4
    ===================================

    © 1987-2005 Vrije Universiteit, Amsterdam
    2010-08-08

    ...

    SUPPORT
    =======

    Languages:

    ANSI C, Pascal, Modula 2. K&R is supported via the ANSI C compiler.



    А где здесь, собсно, ANSI C?

    Pythoner, 23 Апреля 2014

    Комментарии (8)
  10. Си / Говнокод #15806

    +141

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    ...
    else if ( (!BG_InSpecialJump( legsAnim )//not in a special jump anim 
    						||BG_InReboundJump( legsAnim )//we're already in a rebound
    						||BG_InBackFlip( legsAnim ) )//a backflip (needed so you can jump off a wall behind you)
    					//&& pm->ps->velocity[2] <= 0 
    					&& pm->ps->velocity[2] > -1200 //not falling down very fast
    					&& !(pm->ps->pm_flags&PMF_JUMP_HELD)//have to have released jump since last press
    					&& (pm->cmd.forwardmove||pm->cmd.rightmove)//pushing in a direction
    					//&& pm->ps->forceRageRecoveryTime < pm->cmd.serverTime	//not in a force Rage recovery period
    					&& pm->ps->fd.forcePowerLevel[FP_LEVITATION] > FORCE_LEVEL_2//level 3 jump or better
    					//&& WP_ForcePowerAvailable( pm->gent, FP_LEVITATION, 10 )//have enough force power to do another one
    					&& BG_CanUseFPNow(pm->gametype, pm->ps, pm->cmd.serverTime, FP_LEVITATION)
    					&& (pm->ps->origin[2]-pm->ps->fd.forceJumpZStart) < (forceJumpHeightMax[FORCE_LEVEL_3]-(BG_ForceWallJumpStrength()/2.0f)) //can fit at least one more wall jump in (yes, using "magic numbers"... for now)
    					//&& (pm->ps->legsAnim == BOTH_JUMP1 || pm->ps->legsAnim == BOTH_INAIR1 ) )//not in a flip or spin or anything
    					)
    			{//see if we're pushing at a wall and jump off it if so
    				if ( allowWallGrabs )
    				{
    					//FIXME: make sure we have enough force power
    					//FIXME: check  to see if we can go any higher
    					//FIXME: limit to a certain number of these in a row?
    					//FIXME: maybe don't require a ucmd direction, just check all 4?
    					//FIXME: should stick to the wall for a second, then push off...
    ...

    Больше условий богу условий!
    Jedi Academy source, 2003

    gost, 21 Апреля 2014

    Комментарии (7)