Си диез / Говнокод #1276 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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
static void Menu()
        {
            ATD atd = new ATD();
            int i = 0; String s;

            while (i!=6){
            
            Console.WriteLine("Пожалуйста, укажите необходимое действие:");
            Console.WriteLine("*******************************************");
            Console.WriteLine("1) Добавить элемент в список");
            Console.WriteLine("2) Просмотреть список");
            Console.WriteLine("3) Сортировать список");
            Console.WriteLine("4) Найти элементы");
            Console.WriteLine("5) Удалить элемент из списка");
            Console.WriteLine("6) Выход");
            Console.WriteLine("*******************************************");
            Console.WriteLine();
            Console.Write("->"); 
            s = Console.ReadLine();
            i = Convert.ToInt32(s);
            Console.WriteLine();
           // Console.WriteLine("i = " + i); 

                if (i == 1)  atd.AddElement(); 
                else if (i == 2) atd.WriteList();
                else if (i == 3) atd.SortList(); 
                else if (i == 4) atd.FindElements(); 
                else if (i == 5) atd.DeleteElement(); 
                else if (i == 6) Console.WriteLine("Программа завершена..."); 
                else Console.WriteLine("Введите корректное значение!");
            Console.WriteLine();
            Console.WriteLine();  
            }

       }

Пример реализации меню.
Автор — неизвестен

guest guest, (Updated )

Комментарии (4, +4)

Няшная / Говнокод #1275 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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
typedef INTEGER int
typedef BOOLEAN bool
#define TRUE true
#define FALSE false
#define BEGIN {
#define END }
#define WHILE(a) while(a)
#define REPEAT do{
#define UNTIL(a) }while(!(a))
#define FOR for(
#define TO(a,b) ,a<b
#define DO(a) ,a++)
#define VAR
#define IF if
#define THEN
...
VAR
INTEGER I;
BEGIN
I=2;
REPEAT
...
I=I+1;
UNTIL I<5;
...
END
...

Что этот парень пытался сделать с Си? O_o

guest guest, (Updated )

Комментарии (21, +21)

Няшная / Говнокод #1274 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
/* sent by Stephan Hughson - 2003 */
/* must be compiled with cc or g++*/

#include <stdio.h>

int main(int t,int _,char*a)
{return!0<t?t<3?main(-79,-13,a+main(-87,1-_,
main(-86, 0, a+1 )+a)):1,t<_?main(t+1, _, a ):3,main ( -94, -27+t, a
)&&t == 2 ?_<13 ?main ( 2, _+1, "%s %d %d\n" ):9:16:t<0?t<-72?main(_,
t,"@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l,+,/n{n+\
,/+#n+,/#;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l q#'+d'K#!/\
+k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;# ){n\
l]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#\
n'wk nw' iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c \
;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;\
#'rdq#w! nr'/ ') }+}{rl#'{n' ')# }'+}##(!!/")
:t<-50?_==*a ?putchar(a[31]):main(-65,_,a+1):main((*a == '/')+t,_,a\
+1 ):0<t?main ( 2, 2 , "%s"):*a=='/'||main(0,main(-61,*a, "!ek;dc \
i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"),a+1);}

Вот результат работы программы(всё не вместилось):
On the first day of Christmas my true love gave to me
a partridge in a pear tree.

On the second day of Christmas my true love gave to me
two turtle doves
and a partridge in a pear tree.

...

On the eighth day of Christmas my true love gave to me
eight maids a-milking, seven swans a-swimming,
six geese a-laying, five gold rings;
four calling birds, three french hens, two turtle doves
and a partridge in a pear tree.

On the ninth day of Christmas my true love gave to me
nine ladies dancing, eight maids a-milking, seven swans a-swimming,
six geese a-laying, five gold rings;
four calling birds, three french hens, two turtle doves
and a partridge in a pear tree.

On the tenth day of Christmas my true love gave to me
ten lords a-leaping,
nine ladies dancing, eight maids a-milking, seven swans a-swimming,
six geese a-laying, five gold rings;
four calling birds, three french hens, two turtle doves
and a partridge in a pear tree.

On the eleventh day of Christmas my true love gave to me
eleven pipers piping, ten lords a-leaping,
nine ladies dancing, eight maids a-milking, seven swans a-swimming,
six geese a-laying, five gold rings;
four calling birds, three french hens, two turtle doves
and a partridge in a pear tree.

On the twelfth day of Christmas my true love gave to me
twelve drummers drumming, eleven pipers piping, ten lords a-leaping,
nine ladies dancing, eight maids a-milking, seven swans a-swimming,
six geese a-laying, five gold rings;
four calling birds, three french hens, two turtle doves
and a partridge in a pear tree.

guest guest, (Updated )

Комментарии (36, +36)

Кресты / Говнокод #1272 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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
  100. 100
// Begin Init Filter
void initFilter(){
   int i,j;
   double Pgam,Ptet,Ppsi,
   sin_psi,cos_psi,sin_gam,cos_gam,cos_tet,
   Pl,Pb,uu[81],bb[81];  //  

     hfo=1.; Nsf=1;
     sugl[0]=1.5*M_PI/180.; sugl[1]=0.1*M_PI/180;sugl[2]=sugl[1];
     dbc=100.; dbc*=0.157236869549e-7; dlc=dbc; dac=sugl[0];
     Rk[0]=Omz/100000000.*hfo; Rk[1]=Omz/100000000.*hfo; Rk[2]=Rk[0];
     Rk[3]=Omz/100000000.*hfo; Rk[4]=Rk[3]; Rk[5]=Rk[3];
     for(i=0;i<3;i++) {
     DTet[i]=0.;
     Xs[i]=0.;
    }
    for(i=0;i<3;i++)  {
    som[i]=0.1*M_PI/(180.0*3600.0);          // som[i]=3.*M_PI/(180.0*3600.0);
   }
    som[0]=0.1*M_PI/(180.0*3600.0);          //som[0]=2.*M_PI/(180.0*3600.0);
    Tauom[0]=360.;                         //  Tauom[0]=300.;
    Tauom[1]=360.;                         //  Tauom[1]=100.;
    Tauom[2]=360.;                         //  Tauom[2]=300.;
 for(i=0;i<9;i++)  {
  for(j=0;j<9;j++) {
   Fko[i][j]=0.;
   Fo[i][j]=0.;
   Pko[i][j]=0.;
  }
  Xko[i]=0.;
  Fko[i][i]=1.;
  Fo[i][i]=1.;
 }

 for(i=0;i<6;i++)  {
  for(j=0;j<9;j++)
   Hizo[i][j]=0.;
 }

 for(i=0;i<9;i++)  {
  for(j=0;j<3;j++)
   Gko[i][j]=0.;
 }
//begin SKO for MNK
  Pgam=sugl[2]*sugl[2]; Ptet=sugl[1]*sugl[1]; Ppsi=sugl[0]*sugl[0];
  Pl=dlc*dlc; Pb=dbc*dbc;
  sin_psi=sin(Angl[0]); cos_psi=cos(Angl[0]);
  sin_gam=sin(Angl[2]); cos_gam=cos(Angl[2]);
  cos_tet=cos(Angl[1]);


 uu[0]=Ur[0][0]*Ur[0][0];           bb[0]=B3[0][0]*B3[0][0];
 uu[1]=Ur[0][0]*Ur[0][1];           bb[1]=B3[0][0]*B3[0][1];
 uu[2]=Ur[0][0]*Ur[0][2];           bb[2]=B3[0][0]*B3[0][2];
 uu[3]=Ur[0][0]*Ur[1][0];           bb[3]=B3[0][0]*B3[1][0];
 uu[4]=Ur[0][0]*Ur[1][1];           bb[4]=B3[0][0]*B3[1][1];
 uu[5]=Ur[0][0]*Ur[1][2];           bb[5]=B3[0][0]*B3[1][2];
 uu[6]=Ur[0][0]*Ur[2][0];           bb[6]=B3[0][0]*B3[2][0];
 uu[7]=Ur[0][0]*Ur[2][1];           bb[7]=B3[0][0]*B3[2][1];
 uu[8]=Ur[0][0]*Ur[2][2];           bb[8]=B3[0][0]*B3[2][2];

 uu[9]=Ur[0][1]*Ur[0][1];           bb[9]=B3[0][1]*B3[0][1];
 uu[10]=Ur[0][1]*Ur[0][2];          bb[10]=B3[0][1]*B3[0][2];
 uu[11]=Ur[0][1]*Ur[1][0];          bb[11]=B3[0][1]*B3[1][0];
 uu[12]=Ur[0][1]*Ur[1][1];          bb[12]=B3[0][1]*B3[1][1];
 uu[13]=Ur[0][1]*Ur[1][2];          bb[13]=B3[0][1]*B3[1][2];
 uu[14]=Ur[0][1]*Ur[2][0];          bb[14]=B3[0][1]*B3[2][0];
 uu[15]=Ur[0][1]*Ur[2][1];          bb[15]=B3[0][1]*B3[2][1];
 uu[16]=Ur[0][1]*Ur[2][2];          bb[16]=B3[0][1]*B3[2][2];

 uu[17]=Ur[0][2]*Ur[0][2];          bb[17]=B3[0][2]*B3[0][2];
 uu[18]=Ur[0][2]*Ur[1][0];          bb[18]=B3[0][2]*B3[1][0];
 uu[19]=Ur[0][2]*Ur[1][1];          bb[19]=B3[0][2]*B3[1][1];
 uu[20]=Ur[0][2]*Ur[1][2];          bb[20]=B3[0][2]*B3[1][2];
 uu[21]=Ur[0][2]*Ur[2][0];          bb[21]=B3[0][2]*B3[2][0];
 uu[22]=Ur[0][2]*Ur[2][1];          bb[22]=B3[0][2]*B3[2][1];
 uu[23]=Ur[0][2]*Ur[2][2];          bb[23]=B3[0][2]*B3[2][2];

 uu[24]=Ur[1][0]*Ur[1][0];          bb[24]=B3[1][0]*B3[1][0];
 uu[25]=Ur[1][0]*Ur[1][1];          bb[25]=B3[1][0]*B3[1][1];
 uu[26]=Ur[1][0]*Ur[1][2];          bb[26]=B3[1][0]*B3[1][2];
 uu[27]=Ur[1][0]*Ur[2][0];          bb[27]=B3[1][0]*B3[2][0];
 uu[28]=Ur[1][0]*Ur[2][1];          bb[28]=B3[1][0]*B3[2][1];
 uu[29]=Ur[1][0]*Ur[2][2];          bb[29]=B3[1][0]*B3[2][2];

 uu[30]=Ur[1][1]*Ur[1][1];          bb[30]=B3[1][1]*B3[1][1];
 uu[31]=Ur[1][1]*Ur[1][2];          bb[31]=B3[1][1]*B3[1][2];
 uu[32]=Ur[1][1]*Ur[2][0];          bb[32]=B3[1][1]*B3[2][0];
 uu[33]=Ur[1][1]*Ur[2][1];          bb[33]=B3[1][1]*B3[2][1];
 uu[34]=Ur[1][1]*Ur[2][2];          bb[34]=B3[1][1]*B3[2][2];

 uu[35]=Ur[1][2]*Ur[1][2];          bb[35]=B3[1][2]*B3[1][2];
 uu[36]=Ur[1][2]*Ur[2][0];          bb[36]=B3[1][2]*B3[2][0];
 uu[37]=Ur[1][2]*Ur[2][1];          bb[37]=B3[1][2]*B3[2][1];
 uu[38]=Ur[1][2]*Ur[2][2];          bb[38]=B3[1][2]*B3[2][2];

 uu[39]=Ur[2][0]*Ur[2][0];          bb[39]=B3[2][0]*B3[2][0];
 uu[40]=Ur[2][0]*Ur[2][1];          bb[40]=B3[2][0]*B3[2][1];
 uu[41]=Ur[2][0]*Ur[2][2];          bb[41]=B3[2][0]*B3[2][2];
 и так далее

Не спрашивайте где это использовалось, спать лучше будете)))

guest guest, (Updated )

Комментарии (11, +11)

"PHP" / Говнокод #1271 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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
function splitString($inS)
 {
  $k = strlen($inS);
  $res = array();
  for($i=0;$i<$k;$i++)
   {
    $res[$i] = $inS{$i};
   };
  return($res);
 };

function toTranslit($text)
 {
  $outS = '';
  $data = splitString(trim($text,' -_')); //str_split($text);
  foreach($data as $ch)
   {
    switch($ch)
     {
      case 'А' : $rc = 'a'; break;
      case 'Б' : $rc = 'b'; break;
      case 'В' : $rc = 'v'; break;
//тут очень, очень много букафф... все какие есть...
      case '8' : $rc = '8'; break;
      case '9' : $rc = '9'; break;
      case '0' : $rc = '0'; break;
      case '-' : $rc = '-'; break;
      case '_' : $rc = '_'; break;
      case ' ' : $rc = '-'; break;
      default : $rc = '';
     };
    $outS .= $rc;
   };
  $outS = str_replace('_','-',$outS);
  while(strpos('--',$outS)) { $outS = str_replace('--','-',$outS); };
  return($outS);
 };

ещё из просеивания, пара функций преобразующая введённую пользователем строчку в транслит
уходит корнями в 2002й год -- продержалась в ядре CMS-ки аж 7 лет, исправно при этом работая.
...и ведь опять я сам писал, заразу...

guest guest, (Updated )

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

"PHP" / Говнокод #1270 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
<?php
//много кода
  if(($ln > 0) && ($ln <= $limit))
//обработка строчки $ln
   } elseif($ln < 1) {
    echo("Нельзя вводить пустую строку!<BR>\n");
   } elseif($ln > $limit) {
    echo("Вы ввели слишком много<BR>\n");
   } else {
    echo("Невыясненный облом<BR>\n");
   };
//дальше много кода
?>

при апе major версии нашей CMS контролирую тщательное просеивание старого кода.
иногда находятся такие хохмочки...
...эту я сам писал, лет уже не помню сколько назад, она уже 3 версии зараза пережила... только сейчас заметил.

guest guest, (Updated )

Комментарии (4, +4)

Си диез / Говнокод #1268 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
string insertSQL;
insertSQL = "INSERT INTO Authors (";
insertSQL += "au_id, au_fname, au_lname, ";
insertSQL += "phone, address, city, state, zip, contract) ";
insertSQL += "VALUES ('";
insertSQL += txtID.Text + "', '";
insertSQL += txtFirstName.Text + "', '";
insertSQL += txtLastName.Text + "', '";
insertSQL += txtPhone.Text + "', '";
insertSQL += txtAddress.Text + "', '";
insertSQL += txtCity.Text + "', '";
insertSQL += txtState.Text + "', '";
insertSQL += txtZip.Text + "', '";
insertSQL += Convert.ToInt16(chkContract.Checked) + "')";

Из книги "Beginning ASP.NET"

guest guest, (Updated )

Комментарии (20, +20)