1. Лучший говнокод

    В номинации:
    За время:
  2. Си / Говнокод #7170

    +148

    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 <conio.h>
    #include <iostream>
    #include <string.h>
    #include <io.h>
    #include <fcntl.h>
    
    struct student {
    	char FIO[40];
    	char Group[10];
    	int TaoN;
    	char Ball[3];
    }qt,st,zt,*zap;
    int flen(char * fname){
    	int handle, len;
    	handle = open(fname,O_RDWR);
    	len = filelength(handle);
    	close(handle);
    	return len;
    }
    void writte(FILE *f){
    
    	int  ret;
    	
    	printf("\t\t\tЗАПОЛНЕНИЕ БАЗЫ:\n\n");
    	printf("ФИО:\t\t");
    	scanf("%s", &st.FIO);
    	printf("ГРУППА:\t\t");
    	scanf("%s", &st.Group);
    	printf("НОМЕР ЗАЧЕТКИ:\t");
    	scanf("%d", &st.TaoN);
    	printf("БАЛЛ:\t\t");
    	scanf("%s", &st.Ball);
    
    	ret = atoi(st.Ball);
    	
    	for(;;)
    	if((ret != 1) && (ret != 2) && (ret != 3) && (ret != 4) && (ret != 5)){
    		printf("Неверный символ. Введите число\n");
    		printf("БАЛЛ:\t\t");
    		scanf("%s", &st.Ball);
    		ret = atoi(st.Ball);
    	}
    	else break;
    			
    	f = fopen("data.txt","a+");
    	fwrite(&st, sizeof(st), 1, f);
    fclose(f);
    
    };
    void readd(student st,FILE *f){
    	int len,i,n;
    
    	system("cls");
    	printf("\t\t\tЧТЕНИЕ БАЗЫ:\n\n");
    
    	f = fopen("data.txt","r+");
    	len = flen("data.txt");
    	n = len/sizeof(st);
    
    	for(i = 0; i < n; i++)
    	{
    		fread(&st, sizeof(st), 1, f);		
    		printf("ФИО:\t\t%s\n", st.FIO);
    		printf("ГРУППА:\t\t%s\n", st.Group);
    		printf("ЗАЧЕТКА:\t%d\n", st.TaoN);
    		printf("БАЛЛ:\t\t%d\n", st.Ball);
    	printf("\n");
    	}
    	
    }
    void Searc(student zt,student st,FILE *f){
    	int len, n, i;
    
    	system("cls");
    	printf("\t\t\tПОИСК В БАЗЕ:\n\n");
    	printf("ФИО: ");
    	scanf("%s", &zt.FIO);
    	printf("\n");
    
    	if (strlen(zt.FIO) != 0){
    		f = fopen("data.txt","r+");
    		len = flen("data.txt");
    			n = len/sizeof(st);
    		for(i = 0; i < n; i++){
    			fread(&st, sizeof(st), 1, f);
    			int rt = strcmp(st.FIO, zt.FIO);
    			if (rt == 0)
    			{
    				printf("ФИО: ");
    				printf("\t\t%s\n", st.FIO);
    				printf("ГРУППА: ");
    				printf("\t%s\n", st.Group);
    				printf("ЗАЧЕТКА: ");
    				printf("\t%d\n", st.TaoN);
    				printf("БАЛЛ: ");
    				printf("\t\t%d\n", st.Ball,"\n");
    			}
    		}

    Chekist, 06 Июля 2011

    Комментарии (22)
  3. PHP / Говнокод #7140

    +148

    1. 1
    2. 2
    // Получаем объект логгера
    $this->logger = nvCommandLogger::getInstance();

    Спасибо, Кэп!

    nord_ua, 04 Июля 2011

    Комментарии (6)
  4. Java / Говнокод #7060

    +148

    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
    99. 99
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.image.BufferedImage;
    import javax.swing.JFrame;
    public class Main extends JFrame{
        static int a=100;
        BufferedImage offscreen = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
    	static double p1[][]={{-a},{0},{a}};
    	static double p2[][]={{0},{-a},{a}};
    	static double p3[][]={{a},{-a},{a}};
    	static double p4[][]={{a},{a},{a}};
    	static double p5[][]={{-a},{a},{a}};	
    	static double p6[][]={{-a},{0},{-a}};
    	static double p7[][]={{0},{-a},{-a}};
    	static double p8[][]={{a},{-a},{-a}};
    	static double p9[][]={{a},{a},{-a}};
    	static double p10[][]={{-a},{a},{-a}};
    	static double mas[][][]=new double[10][][];
    	
    	public static void main(String[] args) {
    		Main mf=new Main();
    		mf.setVisible(true);
    		mf.setSize(800,800);
    		mf.setDefaultCloseOperation(EXIT_ON_CLOSE);
    		
    		Matrix P1=new Matrix(p1);
    		Matrix P2=new Matrix(p2);
    		Matrix P3=new Matrix(p3);
    		Matrix P4=new Matrix(p4);
    		Matrix P5=new Matrix(p5);
    		Matrix P6=new Matrix(p6);
    		Matrix P7=new Matrix(p7);
    		Matrix P8=new Matrix(p8);
    		Matrix P9=new Matrix(p9);
    		Matrix P10=new Matrix(p10);
    		
    		double a=0;
    		while(true){
    			Matrix ox=new OX(a);
    			Matrix oy=new OY(a);
    			Matrix oz=new OZ(a);
    			Matrix m=ox.multiplication(oy.multiplication(oz));
    			mas[0]=m.multiplication(P1).getData();
    			mas[1]=m.multiplication(P2).getData();	
    			mas[2]=m.multiplication(P3).getData();	
    			mas[3]=m.multiplication(P4).getData();
    			mas[4]=m.multiplication(P5).getData();
    			mas[5]=m.multiplication(P6).getData();	
    			mas[6]=m.multiplication(P7).getData();	
    			mas[7]=m.multiplication(P8).getData();
    			mas[8]=m.multiplication(P9).getData();	
    			mas[9]=m.multiplication(P10).getData();
    			a+=0.06;
    			//a=0;
    			mf.repaint();
    			try {
    				Thread.sleep(100);
    			} catch (InterruptedException e) {
    				// TODO Auto-generated catch block
    				e.printStackTrace();
    			}
    		}
    	}
       
    	public void paint(Graphics g){
    		super.paint(g);
    		this.display(mas);
    	}
    	
    	public void display(double m[][][]){
    		Graphics g= this.getGraphics();
    		g.setColor(Color.BLACK);
    		for(int i=0;i<m.length;i++){
    			m[i][0][0]+=300;
    			m[i][1][0]+=300;
    		}
    		g.drawLine((int)m[0][0][0],(int)m[0][1][0],(int)m[1][0][0],(int)m[1][1][0]);
    		g.drawLine((int)m[1][0][0],(int)m[1][1][0],(int)m[2][0][0],(int)m[2][1][0]);
    		g.drawLine((int)m[2][0][0],(int)m[2][1][0],(int)m[3][0][0],(int)m[3][1][0]);
    		g.drawLine((int)m[3][0][0],(int)m[3][1][0],(int)m[4][0][0],(int)m[4][1][0]);
    		g.drawLine((int)m[4][0][0],(int)m[4][1][0],(int)m[0][0][0],(int)m[0][1][0]);
    		g.drawLine((int)m[5][0][0],(int)m[5][1][0],(int)m[6][0][0],(int)m[6][1][0]);
    		g.drawLine((int)m[6][0][0],(int)m[6][1][0],(int)m[7][0][0],(int)m[7][1][0]);
    		g.drawLine((int)m[7][0][0],(int)m[7][1][0],(int)m[8][0][0],(int)m[8][1][0]);
    		g.drawLine((int)m[8][0][0],(int)m[8][1][0],(int)m[9][0][0],(int)m[9][1][0]);
    		g.drawLine((int)m[9][0][0],(int)m[9][1][0],(int)m[5][0][0],(int)m[5][1][0]);
    		g.drawLine((int)m[0][0][0],(int)m[0][1][0],(int)m[5][0][0],(int)m[5][1][0]);
    		g.drawLine((int)m[1][0][0],(int)m[1][1][0],(int)m[6][0][0],(int)m[6][1][0]);
    		g.drawLine((int)m[2][0][0],(int)m[2][1][0],(int)m[7][0][0],(int)m[7][1][0]);
    		g.drawLine((int)m[3][0][0],(int)m[3][1][0],(int)m[8][0][0],(int)m[8][1][0]);
    		g.drawLine((int)m[4][0][0],(int)m[4][1][0],(int)m[9][0][0],(int)m[9][1][0]);
    		Graphics g2 =  offscreen.getGraphics();
            g2.setColor(Color.WHITE);
            g2.fillRect(0, 0, getWidth(), getHeight());
            g2.setColor(Color.BLUE);
            g2.fillRect(0, 0, 100, 100);
            g.drawImage(offscreen, 0, 0, null);
    	}
    }

    Говнолаба по предмету "компьютерная графика".
    Задача: нарисовать куб с усеченным углом, повернутый на произвольный угол вокруг трех осей (OX, OY, OZ).
    Вот как эту задачу решает мой однокурсник.
    Вместо того, чтобы использовать одну матрицу поворота, он создает 10 матриц для каждой из 10 точек...
    Впрочем, код лучше расскажет...

    just_nameless, 26 Июня 2011

    Комментарии (13)
  5. C++ / Говнокод #7000

    +148

    1. 1
    2. 2
    3. 3
    4. 4
    int getGKnumber()
    {
       return 7000;
    }

    просто гет :)

    absolut, 19 Июня 2011

    Комментарии (87)
  6. PHP / Говнокод #6941

    +148

    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
    <?php
    
    class CodeCounter {
        const MULTILINE_COMMENT = 0x01;
    
        private $dir = null;
        private $ext = null;
    
        public function __construct($dir = '.', $ext = '*') {
            $this->dir = $dir;
            if($ext == '*') {
                $this->ext = "/.*/si";
            } else {
                $e = explode('|', $ext);
                foreach($e as &$ext) {
                    $ext = trim($ext);
                    if($ext == '')
                        unset($ext);
                }
                $r = implode('|', $e);
                $this->ext = "/.*\.({$r})$/si";
            }
    
        }
    
        public function calculate() {
            $lines = 0;
            $args = func_get_args();
            if(count($args) == 0)
                $dir = $this->dir;
            else
                $dir = $args[0];
            if(file_exists($dir) && is_dir($dir)) {
                $list = scandir($dir);
                foreach($list as $item) {
                    if($item == '.' || $item == '..')
                        continue;
                    $fullItem = realpath($dir . DIRECTORY_SEPARATOR . $item);
                    if(is_dir($fullItem)) {
                        $lines += $this->calculate($fullItem);
                    } else {
                        if(preg_match($this->ext, $item)) {
                            echo "Calculating lines in {$fullItem}:  ";
                            $_lines = self::count($fullItem);
                            echo "{$_lines}\n";
                            $lines += $_lines;
                        }
                    }
                }
            }
            return $lines;
        }
    
        private static function count($file) {
            $lines = 0;
            $d = null;
            if(file_exists($file) && ($file = file($file))) {
                foreach($file as $line) {
                    $line = trim($line);
                    if($line == '')
                        continue;
                    if( substr($line, 0, 2) == '//' || //single line comment
                        substr($line, 0, 1) == '#'  || //single line comment
                        substr($line, 0, 2) == '<?' || //php open tag
                        substr($line, 0, 2) == '?>'    //php close tags
                    )
                        continue;
                    if(($pos = strpos('/*', $line)) !== false) {
                        if($pos == 0) {
                            if(strpos('*/', $line, $pos) === false) {
                                $d = self::MULTILINE_COMMENT;
                            }
                        } else {
                            $lines++;
                        }
                        continue;
                    }
                    if($d == self::MULTILINE_COMMENT) {
                        if(strpos('*/', $line) !== false) {
                            $d = null;
                        }
                        continue;
                    }
                    $lines++;
                }
            }
            return $lines;
        }
    }
    
    $counter = new CodeCounter('./amapys', 'php|js');
    $lines = $counter->calculate();
    echo "\nTotal: {$lines} lines\n";

    Автор: POPSuL
    Пхп-шники такие пхп-шники.
    ООП во все поля. Им неведом sed и awk.

    cutwater, 13 Июня 2011

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

    +148

    1. 1
    2. 2
    3. 3
    4. 4
    if((s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) die("socket creating.");
    if(bind(s, (struct sockaddr*) &local, sizeof(struct sockaddr_in)) == SOCKET_ERROR) die("bind...");
    if(ioctlsocket(s, FIONBIO, &on) != 0) die("IOCTL!!!");
    if(listen(s, 16) != 0) die("WHYYYYY?!?!!!!!");

    No hard feelings.

    danilissimus, 29 Мая 2011

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

    +148

    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
    void DayNumbSat (double day, int month, double year, double days) {
         
         int FirstJan, DayNumb; 
         char *Sat;
    
         FirstJan = (long) days%7 - 1;
         
         
         switch ( month ) {
              case 1: DayNumb = day;
              break;
              case 2: DayNumb = 31 + day;
              break;
              case 3: DayNumb = 31 + 28 + day;
              break;
              case 4: DayNumb = 31*2 + 28 + day;
              break;
              case 5: DayNumb = 31*2 + 28 + 30 + day;
              break;
              case 6: DayNumb = 31*3 + 28 + 30 + day;
              break;
              case 7: DayNumb = 31*3 + 28 + 30*2+day;
              break;
              case 8: DayNumb = 31*4 + 28 + 30*2 + day;
              break;
              case 9: DayNumb = 31*5 + 28 + 30*2 + day;
              break;
              case 10: DayNumb = 31*5 + 28 + 30*3 +day;
              break;
              case 11: DayNumb = 31*6 + 28 + 30*3 +day;
              break;
              case 12: DayNumb = 31*7+30*4+28+day;
              break;
         }
    
         printf("\n%d  PASSED SINCE 1ST OF JANUARY\n", DayNumb);

    govnoval, 12 Мая 2011

    Комментарии (25)
  9. Куча / Говнокод #6445

    +148

    1. 1
    А может, стоит добавить категорию для лаб/уроков? А то искать искры истинных какашек среди php-datetime'ов и студенческих поделок становится действительно трудно.

    byss, 21 Апреля 2011

    Комментарии (21)
  10. PHP / Говнокод #6043

    +148

    1. 1
    preg_replace('/^(.*)\s(.*)$/i', '$1', $item['updated']);

    DrFreez, 20 Марта 2011

    Комментарии (8)
  11. PHP / Говнокод #5305

    +148

    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
    $take_mod = mysql_query("select * from `cpdb`.`".$mod."`;");
    			
    $rows = mysql_num_rows($take_mod);
    $fields = mysql_num_fields($take_mod);
    
    		### Вывод БД<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    	
    			echo '<td width="100%" height="26" valign="center">';			
    			### Создание названия полей____________
    		
    				echo "<table border=3px>";
    				echo "<tr>";
    				for ($b=0; $b<$fields; $b++)
    				{
    					echo "<td bgcolor='#CCFFFF'>".mysql_field_name ($take_mod, $b)."</td>";
    				}
    				echo "</tr>";
    		
    			### Содержание БД____________
    				for ($c=0; $c<$rows; $c++) {
    				 	echo "<tr>";
    					echo "<td>".mysql_result($take_mod, $c, 0)."</td>";				
    					for ($cc=1; $cc<$fields; $cc++) {
    						if($mod == 'img'){
    							echo "<td><img src='../images/100/".mysql_result($take_mod, $c, $cc)."'  width='200'/></td>";
    						}
    						else{
    							echo "<td>".mysql_result($take_mod, $c, $cc)."</td>";
    						}
    				    }
    				
    					$edit_id = $c;
    					$drop_id = mysql_result($take_mod, $c, 0);
    				
    					echo '<td width="25" bgcolor="#CCFFFF" align="center" valign="middle" >
    					<a href="?key=2&mod='.$mod.'&edit_id= '.$edit_id.'"><img src="img/b_edit.png" alt="Изменить" /></a></td>';
    					echo '<td width="25" bgcolor="#CCFFFF" align="center" valign="middle" >
    					<a href="?key=2&mod='.$mod.'&id_del='.$drop_id.'"><img src="img/b_drop.png" alt="Удалить" /></a></td>';
    
    				  	echo "</tr>";
    					}
    				echo "</table>";
    			echo '</td>';

    Это CMS - мегавывод записей БД для выбора: редактирование или удаление записи.
    Я пока только догадываюсь, что это мой мега высер..))) И пока еще не опечален)..

    Hello_O, 17 Января 2011

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