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

    −3

    1. 1
    O say, can you see, by the dawn’s early light,

    guestinho, 20 Января 2017

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

    +4

    1. 1
    #define KdpQuickMoveMemory(dst, src, len)     memcpy((dst), (src), (len))

    dm_fomenok, 17 Января 2017

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

    0

    1. 1
    https://www.quora.com/What-do-the-Windows-Kernel-team-think-of-Linux

    I was involved in Windows Kernel at one time. I can tell you that for a programmer Linux Kernel code is 1000 times easier than Windows. Here’s why.

    In Windows Kernel code you will find a lot pointer arithmetic, bit shifting, highly optimized calculations at the C and asm level. All these are methods that open source community is highly against of. You do gain a lot of performance using these methods, and the programmers are very proud that they can do this. However, readability, portability and scalability are almost ZERO. It took Microsoft almost 7 years to port Windows Kernel to IA64, yet they abandoned it with Windows Server 2008 R2 (Windows Server 2008 for Itanium-Based Systems Feature Support).

    In Linux kernel you don’t find much of these methods in use. It is rejected by CLANG. Maybe when you’re developing code specific to a certain hardware. So if you’re building a modular kernel, all hardware specific code is in loadable kernel modules.

    Windows programmers think that if they take over Linux Kernel they would do a much better job on Intel version of the Linux Kernel. Other platforms don’t matter to them.

    barop, 16 Января 2017

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

    +5

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    void foo()
    {
      int i;
      if(0 == i)
      {
      	printf("foo\n");
      }
      if(0 != i)
      {
      	printf("bar\n");
      }
    }

    https://godbolt.org/g/TL7tTW
    Ясно

    DlangGovno, 13 Января 2017

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

    +3

    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
    #include <stdio.h>
    #include <string.h>
    #include <stdint.h>
    #include <sys/mman.h>
    
    typedef intptr_t binaryfunc(intptr_t, intptr_t);
    typedef intptr_t unaryfunc(intptr_t);
    
    #define evalsiz ((intptr_t)eval_end - (intptr_t)eval)
    #define clossiz (evalsiz+sizeof(intptr_t)+sizeof(int))
    void eval_end();
    intptr_t eval(intptr_t rem) {
    #define argsize ((intptr_t)&&argend - (intptr_t)eval)
    #define leasize ((intptr_t)&&leaaft - (intptr_t)&&leabef)
    #define eoffset (argsize+leasize)
        argend:;
        register void *ptr asm("r10");
        leabef: asm("lea (%rip),%r10"); leaaft:;
        void *off = (ptr - eoffset + evalsiz);
        binaryfunc *bin = *(binaryfunc**)off;
        return bin(*(intptr_t *)(off+sizeof(intptr_t)),rem);
    }
    void eval_end() { }
    
    unaryfunc* apply(binaryfunc *bin, intptr_t arg) {
        void *data = mmap(0, clossiz, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
        memmove(data, &eval, evalsiz);
        intptr_t ptr = (intptr_t)bin;
        memmove(data+evalsiz, &ptr, sizeof(intptr_t));
        memmove(data+evalsiz+sizeof(intptr_t), &arg, sizeof(intptr_t));
        return data;
    }
    
    intptr_t add(intptr_t a, intptr_t b) {
        return a+b;
    }
    
    int main() {
        printf("%ld\n", apply(add, 1)(2));
        return 0;
    }

    Simple x86_64 closure implementation attempt

    https://gist.github.com/iamtakingiteasy/c80112437ebc1f8d73eecf8df27caa24

    j123123, 01 Января 2017

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

    −2

    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
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    #include<stdio.h>
    #include<stdlib.h>
    #include<time.h>
    #define  MAX  20
    int main(void) {
    	int ext_lab(int row , int col , int exrow, int excol, int lab[][MAX] ,int stp );	int s,d, s_out, d_out;
    	int wave(int lab[][MAX] ,int row , int col ,  int exrow , int excol ,int d  );
    	void create_lab(	int  lab[][MAX]);
    	void gen_entrance_exit(int lab[][MAX] , int *x , int  *y ,  int *x_out , int *y_out  );
    	void view_lab(	int  lab[][MAX]); int lb[MAX][MAX]  ;	 	void	gen_lav(int lab[][MAX]);	void step_lab(int lab[][MAX] , int row , int  col  );
    	srand(time(0));		
    	int ext_lab(int row, int col,int exrow, int excol, int lab[][MAX], int stp);
    		create_lab(lb);
    		gen_lav( lb );
    		gen_entrance_exit(lb , &s, &d, &s_out, &d_out  );
    		wave(lb  ,s, d ,s_out,d_out  , 0 );	
    		ext_lab( s , d ,s_out, d_out, lb , 1 ); 
    	while(lb[s_out][d_out] == 0	){
    		create_lab(lb);
    		gen_lav( lb );
    		gen_entrance_exit(lb , &s, &d, &s_out, &d_out  );
    		wave(lb  ,s, d ,s_out,d_out  , 0 );	
    		ext_lab( s , d ,s_out, d_out, lb , 1 ); 
    }		lb[s_out][d_out] = 1;
    		view_lab(lb);	
    	return 0;
    }
    void create_lab(int  lab[][MAX]){
    	int x , y;
    	for( x = 0;x <  MAX  ; x++ ){
    		for(y = 0 ;y < MAX   ; y++ ){
    			lab[x][y] = -1 ;
    		}
    	}
    }
    void view_lab(	int  lab[][MAX]){
    	int x , y ; for(x = 0; x <  MAX ; x++) { puts(" ");
    		for(y = 0 ; y < MAX ; y++)
    			printf    (    lab[x][y] == -1   ?  " # " : "%2d ", lab[x][y]     ) ;
    	}
    }
    void gen_entrance_exit(int lab[][MAX] , int *x , int  *y ,  int *x_out , int *y_out  ){
    	int ent = 0 , ext = 0;
    				while ( ent == ext ){
    				 ent = 1 +  rand() % 4 ;
    				 ext = 1 +  rand() % 4 ;
    				}
    				 switch(ent){
    					case 1:lab[  *x = 0][ *y = 1 + rand() % (MAX - 2)   ]  =  0; break;
    					case 2: lab[  *x = (MAX - 1)  ][ *y = 1 + rand() % (MAX  - 2)   ] = 0; break;
    				    case 3: lab[ *x  = 1 + rand() %  (MAX - 2)  ][ *y = 0  ]  = 0;break;
    					case 4: lab[ *x  = 1 + rand() % (MAX - 2)  ][*y  = (MAX - 1)]  = 0; break;
    					}
    				switch(ext){
    					case 1:lab[ *x_out =  0][*y_out =  1 + rand() % (MAX - 2)]   = 0 ; break;
    					case 2:lab[ *x_out = (MAX - 1)  ][ *y_out = 1 + rand() % (MAX - 2) ]  = 0 ; break;
    					case 3:lab[ *x_out =  1 + rand() % (MAX - 2)  ][  *y_out =  0 ]  = 0; break;
    					case 4:lab[  *x_out = 1 + rand() % (MAX - 2)  ][  *y_out = (MAX - 1)]  = 0 ;break;
    					}
    				}
    void gen_lav(int lab[][MAX]){
    		int  y;
    		for(y = 0 ;y !=  250; y++ ){
    						lab[  1 +  rand() % (MAX - 2)  ][ 1 + rand() % (MAX - 2)  ] = 0 ;}} 
    int wave(int lab[][MAX] ,int row , int col ,  int exrow , int excol ,int d  ){
    if (   (  !lab[row + 1][col]    || lab[row + 1][col]  > d + 1)   &&  (row  < (MAX - 1)  )  ){
    	lab[row + 1 ][col ] =  d + 1; 
    	wave(lab ,row + 1  ,col,exrow ,excol , d + 1  );
    }
    if (   (!lab[row - 1][col  ] || lab[row - 1][col  ] > d + 1 ) && ( row   > 0       )  ){
    	lab[row - 1][col] =  d + 1;
    	wave(lab,row - 1 ,col , exrow ,excol   ,d + 1  );
    }
    if (  (!lab[row][col + 1   ]  || lab[row ][col + 1 ] > d + 1)  && (col  <  (MAX  - 1)  )    ){
    	lab[row ][col + 1 ] =  d + 1;
    	wave(lab,row  ,col + 1 ,exrow ,excol , d + 1  );
    }
    if( (!lab[row][col - 1   ]   || lab[row ][col - 1 ] > d + 1 )  && (col  > 0 )   ){
    	lab[row ][col - 1] =  d + 1;
    		wave(lab,row  ,col - 1 ,  exrow ,excol  ,d + 1  );
    	}
    }
    int ext_lab(int row, int col,int exrow, int excol, int lab[][MAX], int stp){
      if( ( lab[exrow][excol]   - lab[exrow][excol - 1] ) == 1   ){
    		ext_lab( row,  col , exrow,  excol  - 1,  lab , stp + 1 );
    		lab[exrow][excol - 1 ]  = stp + 1; 
    }	else if(  (  lab[exrow][excol]  -      lab[exrow][excol + 1]  ) == 1 )   {
    		ext_lab( row,  col  , exrow ,  excol + 1,  lab , stp + 1 );
    		lab[exrow][excol + 1 ]  = stp + 1; 
    }	else	if(  ( lab[exrow][excol]   -    lab[exrow - 1][excol]   )    ==  1 ){
    		ext_lab( row,  col , exrow  - 1,  excol,  lab , stp + 1 );
    		lab[exrow - 1 ][excol  ]  = stp + 1; 
    }	else	if(   (  lab[exrow][excol]    -      lab[exrow + 1][excol] )  == 1 ){
    		ext_lab( row,  col , exrow  + 1,  excol,  lab , stp + 1 );
    		lab[exrow + 1 ][excol  ]  = stp + 1; 
    	}
    }

    Типа обход лабиринта

    gne4do, 26 Декабря 2016

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

    −3

    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
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    void counting(int in[], int out[]) {
    	int	pls = 0;
    	for (pls = 0; pls < 5; pls++) {
    		++out[in[pls]];
    	}
    }
    int s_t(int ar[] , int r , int  ps , int d  ) {
    	d = ar[ps] ;
    	if(r <= 12 ) {
    		if(d  <  ar[r]   ) {
    			d = ar[r]; ps = r;
    		}
    		return s_t(ar , r + 1, ps, d);
    	}
    	return ps;
    }
    int find_combination(int array[], int array_2[] , int flag  ) {
    	int p[13] = { 0} , flush(int array[]),straight(int array[])	, chck[13] = { 0 } , ks ,sort_select(int arr[],int arr_2[] , int  p, int  up_turn);
    	int s_t(int ar[] , int r , int  ps , int d  );
    	sort_select(array, array_2, 0, 2);
    	counting(array, chck);
    	if( flag == 1) {
    		ks = s_t(chck,0,0,0);
    	} else {
    		sort_select(chck,p, 0, 1);
    		if (chck[0] == 3 &&  chck[1]== 2) {
    			ks = 60;
    		} else if (chck[0] == 4) {
    			ks = 70;
    		} else if (chck[0] == 3) {
    			ks = 30;
    		} else if (chck[0] == 2 && chck[1]  == 2) {
    			ks = 20;
    		} else if (chck[0] == 2) {
    			ks = 10;
    		} else if (straight(array) && flush(array_2)) {
    			ks = 80;
    		} else if (straight(array)) {
    			ks = 40;
    		} else if (flush(array_2)) {
    			ks = 50;
    		} else {
    			ks = 0;
    		}
    	}
    	return ks;
    }
    int straight(int array[]) {
    	int	 b = 1, m = 1;
    	if(array[0] == 0 && array[1] == 1  && array[2] == 2 && array[3] == 3 && array[4] == 12 ) {
    		b = 1;
    	} else {
    		while (m  != 5) {
    			if ( 1 !=  (array[m] - array[m - 1]) ) {
    				b = 0; break;
    			}
    			m++;
    		}
    	}
    	return b;
    }
    void test_straight(int array[], int *flag  ) {
    	int	 m = 1; *flag = 0;
    	while (m  != 5) {
    		if   (  1 != (array[m ]     -   array[m  - 1 ])) {
    			if (array[m] > array[m + 1  ]) {
    				array[m] = -1; *flag += 1;
    			} else  {
    				array[m - 1 ] = -1; *flag += 1;
    			}
    		}
    		m++;
    	}
    }
    int flush(int array[]) {
    	int	f = 0, d = 1;
    	for (f = 1; f < 5; f++) {
    		if (array[0] != array[f] ) {
    			d = 0; break;
    		}
    	}
    	return d;
    }
    void test_pair(int array[]) {
    	int y = -1,x = 0;
    	while(x < 5) {
    		if( array[x] == y   ) {  x++;
    		} else 	if( array[x] != array[x + 1]  ) {
    			array[x] =  -1; x++;
    		} else {
    			y = array[x]; x += 2;
    		}
    	}
    }
    void swap(int *elementptr1, int *elementptr2) {
    	int hold = *elementptr1;
    	*elementptr1 = *elementptr2; *elementptr2 = hold;
    }

    покер 3

    gne4do, 20 Декабря 2016

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

    −3

    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
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    void change_card(  int array_suit[]  ,  int  array_face[] , int deck[][13] ) {
    	int r = 0;
    	void  change_count( int *array_suit, int *array_face , int array_deck[][13], int count);
    	static int y = 11;
    	while( r != 5) {
    		if(array_face[r]  == -1    ) {
    			y++;
    			change_count( &array_suit[r],  &array_face[r], deck,  y);
    		}
    		r++;
    	}
    }
    void change_count(int *array_suit, int *array_face , int array_deck[][13], int count) {
    	int row = 0 , column = 0;
    	for( row = 0 ; row <= 3; row++) {
    		for(  column = 0   ; column <= 12 ; column++) {
    			if(array_deck[row][column] == count ) {
    				*array_suit = row;
    				*array_face = column;
    				break;
    			}
    		}
    	}
    }
    int sort_select(int  arr[], int arr_2[] ,  int p, int up_turn) {
    	void swap(int *elementptr1, int *elementptr2);
    	int search(int st[], int s, int choice, int up_turn);
    	int min;
    	if (p == MAX  ) {
    		return 1;
    	} else {
    		min = search(arr, p, p, up_turn);
    		swap(&arr_2[p], &arr_2[min]);
    		swap(&arr[p], &arr[min]);
    	}
    	return	sort_select(arr, arr_2, p + 1, up_turn);
    }
    int search(int st[], int s, int choice, int turn) {
    	int p;
    	if (turn == 1) {
    		p = MAX ;
    	} else if (turn == 2) {
    		p = 5;
    	}
    	if (s <  p) {
    		if (turn == 1) {
    			if (st[s] >   st[choice]) {
    				choice = s;
    			}
    		} else if (turn == 2) {
    			if (st[s] <   st[choice])
    				choice = s;
    		}
    		return	search(st, s + 1, choice, turn);
    	} else {
    		return choice;
    	}
    }
    void shuffle(int wDeck[][13]) {
    	int row = 0, column = 0, card, tmp = 0, tmp_1 = 0, tmp_2 = 0;
    	void swap(int *elementptr1, int *elementptr2);
    	for (card = 1; card < 52; card++) {
    		tmp_1 = rand() % 3;
    		tmp_2 = rand() % 12;
    		for (row = 0; row <= 3; row++) {
    			for (column = 0; column <= 12; column++) {
    				if (wDeck[row][column] == card) {
    					swap(&wDeck[row][column], &wDeck[tmp_1][tmp_2]);
    				}
    			}
    		}
    	}
    }
    void combi(int wDeck[][13]) {
    	int row , column,card = 1;
    	for (row = 0; row <= 3; row++) {
    		for (column = 0; column <= 12; column++) {
    			wDeck[row][column] = card; card++;
    		}
    	}
    }
    void deal(int wDeck[][13], int gm_suit[], int  gm_face[], int mg_suit[], int  mg_face[]) {
    	int card = 1, row, column, y = 0, x = 0;
    	while (card++ <= 10) {
    		for (row = 0; row <= 3; row++) {
    			for (column = 0; column <= 12; column++) {
    				if (wDeck[row][column] == card) {
    					if (0 == card % 2) {
    						gm_suit[y] = row; gm_face[y] = column;  y++;  break;
    					} else {
    						mg_suit[x] = row; mg_face[x] = column; x++; break;
    					}
    				}
    			}
    		}
    	}
    }

    покер 2

    gne4do, 20 Декабря 2016

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

    −3

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    #include <stdio.h>
    #include <stdlib.h>
    #include <time.h>
    #define MAX 13
    int main(void) {
    	void test_straight(int array[], int *flag  ),  test_flush(int array[], int array_2[]),
    	     test_pair(int array[]),       combi(int wDeck[][13]),
    	     change_card( int array_suit[]  , int array_face[] , int deck[][13] ),   shuffle(int wDeck[][13]),
    	     deal(int wDeck[][13], int gm_suit[], int  gm_face[], int mg_suit[], int  mg_face[]);
    	int   find_combination(int array[], int array_2[], int flag);
    	int  pc_suit[5],  pc_face[5] ,   my_suit[5],my_face[5] , deck[4][13] = { 0 }, m = 0, w = 0,point = 0, f_1 = 0,a,e = 0, d  = 0, f ;
    	const char *suit[4] = { "Hearts", "Diamonds", "Clubs", "Spades" };
    	const char *face[13] = {
    		"Deuce", "Three", "Four",
    		"Five", "Six", "Seven", "Eight",
    		"Nine", "Ten", "Jack", "Queen", "King","Ace"
    	};
    	combi(deck);
    	srand(time(0));
    	shuffle(deck);
    	deal(deck, my_suit, my_face, pc_suit, pc_face);
    	while(d != 5  ) {
    		point  =	find_combination(pc_face, pc_suit, 0 );
    		find_combination(my_face, my_suit, 0  );
    		puts("\t************************");
    		for (m = 0; m < 5; m++) {
    			printf("   %5s pc %8s <> %5s me %8s  %d\n",face[pc_face[m]],suit[pc_suit[m]],face[my_face[m]],suit[my_suit[m]],m);
    		}
    		puts("\t************************\n");
    		while ( e != 5 ) {
    			puts("any button no change: change yes -1");
    			printf("%5s <> %8s", face[my_face[e]] , suit[my_suit[e]]  );
    			scanf("%d", &a);
    			if(a == -1) {
    				my_face[e] = -1;
    			} else if(a ==   7 ) {
    				break;
    			}
    			e++;
    		}
    		if(f_1 == 1  ) {
    			test_straight(pc_face ,&f_1 );
    		} else if(point < 40 )                 {
    			switch(point) {
    				case 30:
    				case 20:
    				case 10:
    					test_pair( pc_face);
    					break;
    				case 0:
    					test_flush(pc_suit , pc_face );
    					change_card(pc_suit,pc_face,deck );
    					point  =	find_combination(pc_face, pc_suit,0 );
    					if(point == 50) {
    						break;
    					} else
    						test_straight(pc_face ,&f_1 );
    					break;
    			}
    		}
    		change_card(my_suit,my_face,deck );
    		change_card(pc_suit,pc_face,deck );
    		if(d <= 3) {
    			puts ("\n\t\tNEXT PART ");
    		}
    		d++;
    		e = 0;
    	}
    	point = find_combination(pc_face, pc_suit, 0);
    	if (find_combination(my_face, my_suit, 0  )  == 	point ) {
    		find_combination(my_face, my_suit, 1  ) > find_combination(pc_face, pc_suit, 1)  ||  my_face[4] > pc_face[4]  ? puts ("\n\t\t YOU WIN")  :  puts ( "\n\t\t YOU LOSE" );
    	} else {
    		find_combination(my_face, my_suit,0)  > 	point  ?  puts ("\n\t\tYOU WIN ")  :  puts ( "\n\t\tYOU LOSE " );
    	}
    	puts("\t******** Game over ***********");
    	for (m = 0; m < 5; m++) {
    		printf("   %5s pc %8s <> %5s me %8s  %d\n",face[pc_face[m]],suit[pc_suit[m]],face[my_face[m]],suit[my_suit[m]],m);
    	}
    	puts("\t******** Game over ***********");
    	return 0;
    }
    void test_flush(      int array[] , int array_2[] ) {
    	int	f = 0, d = 0 , r = 0, p = 0 , n = 1;
    	if(array[0] != array[1] && array[1] == array[2]  && array[2] == array[3] && array[3] == array[4]) {
    		array_2[0] = -1;
    	} else
    		for (f = 0; f != 5; f++) {
    			for(d = 0 ; d != 5; d++) {
    				if(array [f] != array [d]) {
    					r++;
    					n = d;
    				} else {
    					p++;
    				}
    			}
    			if( p == 4 && r == 1  ) {
    				array_2[n]  = -1;
    				break;
    			}
    		}

    Покер 1

    gne4do, 20 Декабря 2016

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

    +2

    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
    #include <stdio.h>
    #include <limits.h>
    #define HOT(love) hot(&love)
    
    const char love[] = {-13, 124, -61, -94, -122, 15, -51, -39, -94, -66, -39, 53, 124, 119, 58, -122};
    char bormand, HACTEHbKA, adventure;
    char passion = 1, beginning = 1, LOVE = 'a';
    
    char story (char bormand, char HACTEHbKA) {
        return ((int) bormand << CHAR_BIT | (int) HACTEHbKA) * 1103515245 + 12345;
    }
    
    int hot (char * love) {
        if (* love == ' ') {
            * love = 'a';
            return 0;
        } else if (* love == 'z') {
            * love = ' ';
        } else {
            (* love) ++;
        }
        return 1;
    }
    
    int main () {
        for (int adventure = beginning; adventure < sizeof(love); ) {
            bormand = HACTEHbKA = LOVE;
            
            do {
                if (story(bormand, HACTEHbKA) == love[adventure - beginning]) {
                    char BORMAND = LOVE;
                    do {
                        if (story(HACTEHbKA, BORMAND) == love[adventure]) {
                            putchar(HACTEHbKA);
                            goto kiss;
                        }
                    } while(HOT(BORMAND));
                }
            } while(HOT(bormand) || HOT(HACTEHbKA));
            
            kiss: adventure += passion;
        }
    }

    HACTEHbKA, 21 Ноября 2016

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