1. Список говнокодов пользователя gne4do

    Всего: 9

  2. Си / Говнокод #24409

    0

    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
    int  removing_mask (int *x , int *y, int *lng  , char board[][Y], 
    					char *content[PL] , int select, void   (*write  )( int x , int y  ,char board[][Y],
    					char *content)  , int search_cross_pnt(char cross_point[LN] , int *point   ,char *content[PL] , int in_x , int in_y) , 
    					int (*chk_mask )(char board[][Y] , int mem ,int sh, int br )
    					   ){
    	char mask_word[LN] = {0}  ;
    	int sm = 1;
    	int lvl   =  0;
    	int shift =  0;
    	int brd = 0;
    	int mem = 0;
    	int stp = 0;
    	int mn = 0;
    	int bi = 0;
    	int rd = 0;
    	int gor = 0 ,vert = 0;
    	int pnt = 0;
    	int hg  = 15;
    	int	sr = 0;
    	int *one_value = 0  , *second_value = 0;
    	int ctr = 0;
        
    	if(select == 0 ){
    	  mem = *y;
    	  hg  = 	  *y < LN	 ?  *y : hg    ;
    	}
    	else   {
    		mem = *x;
    		hg  = 	  *x < LN	 ?  *x : hg    ;
    	
    	}
    	
    	for(   lvl = 0     ,rd = 0; lvl <= *lng  - 1    ;      lvl++  ,mem++	  ){
    		 
    			for(brd = 0  ;    brd  <= hg  ; brd++           ){
    			 	  	
    			 select == 0 ? ( shift = *x ,    one_value = &sr ,   	second_value  =  &mem) :  (shift = *y       ,  one_value = &mem ,   	second_value  = &sr  ) ;
    	
    	if(	 (select == 0 && board[ shift - 1][ *second_value ]  == 0  )  ||  (select == 1 && board[*one_value  ][shift  - 1 ]   == 0    )){
    		
    		for(    pnt = 0, stp = 0;   stp  <= LN  ;stp++     ){
    				   	  
    			if ( 	 chk_mask  ( board  , mem    ,   shift ,  brd  )   == 1   ){
    						 pnt = 1;
    						
    						break;
    				}	
    					sr = shift++ - brd ;
    					mask_word[stp] 	 = 	board[    	*one_value      ][ 	*second_value   ]  ;
    				}
    		     
    	     	}   	 
    				if(pnt == 1 ){
    				     	break;
    					 }
    
    				sm =  search_cross_pnt( mask_word   ,&mn , content  ,*x, *y  ) ; 
    
    			 	if(  sm > bi   ){
    					
    				
    				    select == 0 ? (  gor   =	*x - brd, vert   = 	mem)	: (gor   =	    mem  ,vert   =  *y - brd) ; 
    			        
    					bi = 	sm   ;
    				    rd = mn; 
    			     }
    				}
    			}		 
    			if(  (select == 1 &&  isalpha(board[gor][vert -  1]  ) ||
    			    
    				 (select == 0 &&  isalpha(board[gor - 1 ][vert] )) ||
    				
    				 ( gor && vert  )   ==  0 
    							) ) { 
    			ctr = 1;
    		}
    		if(  ( (    content[rd]   != " " ) )  && 
    			
    			( board[gor ][vert ]  ==  content[rd][0] || !isalpha (board[gor ][vert ]  )  ) 
    		
    			&& !ctr 
    		
    		) {
    			
    			*x = gor  ;   
    			*y = vert ;
    			*lng =   strlen(content[rd ]); 
    			write( gor   , vert    ,  board ,     content[rd]     );
    					content[rd] = " ";
    					return 1 ;
    			}
    	
    			return 0;
    	}

    полный аут кроссворду 3 ч.

    gne4do, 22 Июня 2018

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

    0

    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
    int search_cross_pnt(char cross_point[LN] , int *point   ,char *content[PL] , int in_x, int in_y      ){
    		int x = 0;
    		int y = 0;
    		int m = 0;
    		int key = 0;
    				
    	  	for(x = 0; x <= PL - 1 ; x++)  {
    		   y = strlen(content[x] ) ;
    		   
    		   			for(  m = 0; m <= y; m++ ){
    		   	
    			   
    			   
    			   if(      (   *(cross_point + m ) !=    *(*(content + x ) + m )       &&    *(cross_point + m )  != 0   )   ||    
    			   
    			  				( ((  in_x  + y )  > (X - 1)  )       ||      (  (  in_y  + y  ) > (Y - 1) )  )     ) {
    							  key = 0;
    							  break;
    				} 
    	
    	
    			
    			if( *(cross_point + m )  ==    *(*(content + x ) + m )){
    				  	key++;
    				  } 
    	
    			
    			
    			if( m  ==  y ){
    				*point = x ;   return key ;
    				}
    	           }
    	}
    return 0;
    }
    
    void write_horizantal ( int x , int y      ,char board[][Y] , char *content         ){
    					while( *content  ){
    					*( *(board + x) + y++ )   =    *content++   	   ;  
    				}
    			}
    	
    	void write_vertical( int x , int y  , char board[][Y] , char *content   ){
    			while(    *content  ){
    						 *( *(board + x++ ) + y)     =    *content++   ;  
    				}
    			}
    
    
    	
    	int checking_space_null (char board[][Y] , int mem ,int sh, int br  ){
    		int	slc = 0;
    	
    		if(      	
    		 	 (          board[  ( sh   )     -  br  ][mem  -  1 ] != 0   ||    board[  ( sh   )     -  br  ][mem  +  1 ] != 0     ) &&    
    			   
    			  board[  ( sh   )     -  br  ][mem ]  == 0    )  { 
    					slc = 1;
    				}
    	return slc;
    		}
    
    	int checking_space_one (char board[][Y] , int mem ,int sh, int br ){
    		int	slc = 0;
    			if(      	
    	           
    			   (   board[   mem  -  1   ][  ( sh   )     -  br ] != 0  ||   board[ mem     +  1   ][      ( sh   )     -  br  ] != 0     ) &&    
    			   
    			   
    			     board[  mem    ][  ( sh   )     -  br    ] == 0   	
    		 																 )  {
    					slc = 1;
    			} return slc;
    		}

    дегенератор кроссворда 2 ч.

    gne4do, 22 Июня 2018

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

    −1

    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
    #include<stdio.h>
    #include<stdlib.h>
    #include <time.h>
    #include <locale.h>
    #include <string.h>
    #include <ctype.h>
    #define PL 300
    #define X 35
    #define Y 35
    #define LN 15
    #define MN 2
    
    	int main(void){ 
    
    		char *words[PL] = {
    			"гарпия","ястреб", "самоходка","снайпер","медведь","баркас","ельцин", "пушкин","рязанов","рузвельт","вагонетка","богатырь", "галстук","мебель","вождь","кобра","журналист", "валюта","кабель","реванш", 
    			"фляжка","пирожок", "гайдай","люстра","соль","вантуз","дерево", "крантик","гитара","спилберг", "пижон","европа", "достоевский","самокрутка","адвокат","колыбель","калькулятор", "освальд","остановка","фикус", 
    			"вавилен","мыщъх", "озборн","ильинский","пархоменко","связка","стекло", "крепеж","тайсон","мэйсон","николай","глушитель", "сапфир","служанка","стояк","пфайфер","градусник", "стамбул","маядзаки","эйзенхаур", 
    			"али","колбаса", "яжевика","совок","число","кобель","ожог", "страница","ваучер","пафос", "самокат","хвостик", "дурында","пучков","дворкович","барабас","сурков", "шут","асфальт","токио", 
    			"лепесток","удав", "выстрел","калибр","улов","копенгаген","осло", "калипсо","грунт","процент", "блоха","след", "пружина","монтажник","экран","боромир","оскар", "бобик","курасава","никсон", 
    			"сталкер","ягодица", "глазок","шмель","геринг","монро","бондаренко", "стрела","носок","мачетэ","шпицберген","сталь", "монолит","случай","зуб","малохит","клубника", "золото","чехов","диск", 
    			"форд","чубайс", "пелевин","юматов","молоток","демократия","сократ", "геродот","невзоров","сорокин","макконохи","быков", "штанга","гвоздь","весло","табурет","вопрос", "колдовство","обида","смерчь", 
    			"блэкмор","тезка", "зубик","сноха","порше","тормоз","туше", " сигал","баярский","китано", "лунаход","гагарин", "синематограф","жим","электрика","веретино","шахматы", "кувшин","букварь","символ", 
    			"башня","котенок", "револьвер","леннон","тигр","телефон","хамелеон", "матрас","зубр","техникс","леонов","коппола", "овчарка","ауди","сфинкс","матрос","ленин", "доберман","фролово","банан", 
    			"самосвал","куба", "амстердам","клык","шпиль","мука","край", "чатский","бугур","паскаль","альпы","лодка", "транспорт","гиря","шпагат","боцман","мауддиб", "игра","крыло","окно", 
    			"одежда","кольцо", "монитор","гриб","тетрис","человек","обезьяна", "шахматы","кинг","эллрой","кобейн","немезида", "ванна","волонтер","эхо","икота","пена", "звук","сьемка","отстойник", 
    			"мачо","конверт", "снаряд","писатель","поисковик","бегун","бетон", "коллапс","пожарник","сигнал","балоболка","свекровь", "спойлер","запас","морковь","питбуль","кемерово", "загон","юпитер","вашингтон", 
    			"труба","статуя", "дверь","агрегат","мачта","корень","волчара", "корова","маскит","радзинский","канада","челюсть", "сейлормун","ньютон","дзержинский","шестерня","валькирия", "компот","адам","матрица", 
    			"бетховен","пудель", "деталь","коломбо","рахит","монголия","колба", "конфета","енот","груздь","наполеон","вертухай", "сковородка","гейша","мост","гриль","комедия", "кубрик","ганапольский","паук", 
    			"скороход","крым", "ротшильд","гайдар","пешка","козырь","дерижабль", "магнезия","магнум","рогатка","гайка","штопор", "перевертыш","репортаж","москва","дзедун","меньшов", "пиксель","розетка","гарем", 
    			};
    
    		srand(time(NULL));
    
    		setlocale( LC_ALL,"Russian" );
    
    		void write_vertical( int x , int y , char board[][Y] , char *content );
    
    		void write_horizantal( int x , int y ,char board[][Y] , char *content );
    
    		void(*write[ MN])( int x , int y ,char board[][Y] , char *content ) = {write_vertical,write_horizantal};
    
    		int search_cross_pnt(char cross_point[LN] , int *point   ,char *content[PL] , int in_x , int in_y );
    
    		int checking_space_null (char board[][Y] , int mem ,int sh, int br  );
    
    		int checking_space_one  (char board[][Y] , int mem ,int sh, int br );
    
    		int (*chk_mask[ MN])(char board[][Y] , int mem ,int sh, int br ) = { checking_space_null    ,  checking_space_one  } ;
    
    		int search_cross_pnt(char cross_point[LN] , int *point   ,char *content[PL] , int in_x , int in_y  ) ;
    
    		int n_x = 2   ,   n_y   =  3  ;
    
    		int kk = 0;
    
    		int first =   first = 1 +  rand() % 299 ;
    
    		int lng = strlen(words[first]) ;
    
    		char crossboard[X][Y] = {" "} ;  
    
    		int  removing_mask (int *x , int *y, int *lng , char board[][Y], 
    					char *content[PL], int select, void   (*write  )( int x , int y   ,char board[][Y],
    					char *content ),
    					int search_cross_pnt(char cross_point[LN] , int *point   ,char *content[PL] , int in_x , int in_y) ,     
    					int (*chk_mask )(char board[][Y] , int mem ,int sh, int br ) );      
    			
    
    	write_horizantal( n_x ,  n_y    ,  crossboard , words[first]       );  
    	
    	words[first]   = " ";
    
    	for(removing_mask(  &n_x  , &n_y , &lng  , crossboard , words , kk %  MN , write[kk %  MN] , search_cross_pnt , chk_mask[kk %  MN]   ); 
    			
    			removing_mask(  &n_x  , &n_y , &lng  , crossboard , words , kk %  MN  , write[kk %  MN] , search_cross_pnt , chk_mask[kk %  MN]   )  ; 	                                               
    			
    			kk++ 
    		
    		) ;
    	    		
    				
    			for( n_x  = 0 ;n_x  <= X - 1 ; n_x ++, puts(" ")   ){
    				for(n_y = 0 ;n_y <=   Y  - 1 ;  n_y++ ){
    						     printf("%c " ,  crossboard[n_x ][n_y ]   )  ;	
    					}
    			}
    
    return 0;
    }

    Якобы генератор Кроссворда 1

    gne4do, 22 Июня 2018

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

    +6

    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
    #include<stdio.h>
    #include<stdlib.h>	
    #include<string.h>	
    	int main(void){
    	void run_func(char *map[], char *fnt  , char *km , float *x ,  float *y , int line , int row , int lift    );
    				char *long_met[3][8] = {{"mile","0.621371"  ,  "yard","1093.61" , "fut","3280.84" , "duim","39370.1" } ,
    							{ "mile" ,"1.60934" , "yard","0.0009144" ,  "fut","0.0003048" ,  "duim","0.0000254"},
     			   				{"kilometer","1"  , "meter","1000"  ,   "stmeter","100000" ,   "mmeter","1000000" } }; 
    				char *amount[3][4] = { { "gallon" , "0.264172" ,       "quarta" , "1.05669"     } , 
    						{"gallon" , " 3.78541"  ,     "quarta" , "0.946353"   },
    						{"litr" , "1"  , "mililitr" , "1000"   }};
    				char *mass[3][8] = {   {"eng.tonna","0.984207"  ,  "amer.tonna","1.10231" , "stone","157.473" , "funt","2204.62" } ,
       						{ "eng.tonna" , "1.01605" , "amer.tonna", "0.907185" ,  "stone","0.00635029" ,  "funt","0.000453592"},
    						{"tonna","1" ,         "kilogram" , "1000"  , "miligram","100000"   , "microgram","1000000"  }}; 
    				char **cp;
    				char *buf_data;
    				char *fnt_sys;
    				char *mtr_sys;
    				char *word[100];
    	while(1){
    	int bg  = 0,convert_ch = 3,y = 0, d = 0, numb = 0;
      	float mn =0  , xm = 0 ;
    	printf("%s", "enter data for converter: ");
    		fgets( (char *) word, 99 ,stdin);
    		buf_data = strtok((char *) word, " ");
    		if( ! strcmp(buf_data, "funt.sys"   )     ){
    		convert_ch = 0;	
    		}
    		else	if( ! strcmp(buf_data, "metric.sys"    )     ){
    			convert_ch = 1;	
    		}
    		for( bg = 0 ;  buf_data != NULL;  buf_data = strtok(NULL, " ")  , bg++ ) {
    			switch(bg){
    				case 1:
    					if( !strcmp("long_met" , buf_data  )  ){
    			  			 y	=   sizeof(*long_met) / sizeof(long_met[0][0]); 
    	          	      	                 d	=   sizeof(long_met) /   sizeof(long_met[0][0]); 
    			  		        cp  = &long_met[convert_ch][0]  ;
    					}
    			   		else if(!strcmp("amount" , buf_data  ) ){
    			  			 y	= sizeof(*amount) /  sizeof(amount [0][0]); 
    		            	                 d	= sizeof(amount) /  sizeof(amount[0][0]); 
    				    	        cp = &amount[convert_ch][0] ;
    					}
    				 	else if(!strcmp("mass" , buf_data  ) ){
    				  		 y	= sizeof(*mass ) /  sizeof(mass[0][0]); 
    		         		         d	= sizeof(mass ) /  sizeof(mass[0][0]); 
    				 		 cp = &mass[convert_ch][0] ; 
    					}
    					break;
    				case 2:
    				fnt_sys = buf_data;
    					break;
    				case 3:
    				mtr_sys = buf_data;
    					break;
    				case 4:
    				numb =   atoi(buf_data);
    					break;
    			}
    		}
    		if( !y || !d || !cp || convert_ch == 3 || !numb ){
    	
    			puts("error");
    		}
    		else{
    			run_func( cp,   fnt_sys ,  mtr_sys , &mn ,  &xm , y  , d , convert_ch );
    			if( !mn || !xm  ){
    		puts("error");
    				} else{
    			printf("%f\n" , !convert_ch  ?    (mn  /  xm ) * numb :  (  mn  *  xm   ) * numb         );	
    			}
    		}
    	}
    	return 0;
    	}
    	void run_func(char *map[], char *fnt  , char *km , float *x ,  float *y , int line , int row  , int lift    ){
    		int m ;
    	if(  ( lift )   ){
    			row    -= line;	
    		}
    	for(  m = 0 ; m <= line   ; m++){
    		if(!strcmp(fnt,map[m])){
    			*x = atof(map[m  + 1] )  ;
    			break;
    			}
    		}
    	for( m =   (row  - line) ; m <=  row - 1  ; m++){
    		if( !strcmp( km   ,  map[m] ) ){
    			*y = atof(map[m  + 1 ] );
    			break;
    				}
    			}
    		}

    gne4do, 11 Октября 2017

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

    −15

    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
    double func_atof(char *p){
    	double	 integer = 0.0, div = 1.0 , fract = 0.0 , sign = 1.0;
       if(   *p == 45  ){sign = -1.0, *p++ ; }
    	while ( isdigit(*p)  ) { 
    		integer = ( *p++ )  +  (10.0   *   integer)  -  48.0 ; 
    		}
    	if(*p == 46  ){
    	(*p++ ) ;
    	while (  isdigit(*p) )  {
    		fract = ( *p++ )  +  (10.0   *   fract)  -  48.0  ; 
    		div *= 10;		
    		}
        }
      return    (integer  +   fract  / div )  * sign    ;
    }

    Грустно всё это.

    gne4do, 24 Апреля 2017

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

    −52

    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)
  8. Си / Говнокод #21873

    −52

    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)
  9. Си / Говнокод #21872

    −53

    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)
  10. Си / Говнокод #21871

    −53

    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)