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

    +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
    bool End_Range (FILE * f){
      int tmp;
      tmp = fgetc(f);
      tmp = fgetc(f);
      if (tmp != '\'') fseek(f,-2,1);
      else fseek(f,1,1);
      return tmp == '\'' ? true : false;
    }
    
    void Natural_Merging_Sort (char *name){
      int s1, s2, a1, a2, mark;  FILE *f, *f1, *f2;  s1 = s2 = 1;
      while ( s1 > 0 && s2 > 0 ){
       	 mark = 1; s1 = 0; s2 = 0;
        	 f = fopen(name,"r"); f1 = fopen("nmsort_1","w"); 
    		 f2 = fopen("nmsort_2","w"); fscanf(f,"%d",&a1);
       	 if ( !feof(f) ) fprintf(f1,"%d ",a1);
       	 if ( !feof(f) ) fscanf(f,"%d",&a2);
        	 while ( !feof(f) ){
         		 if ( a2 < a1 ) {switch (mark) {
              				case 1:{fprintf(f1,"' "); mark = 2; s1++; break;}
             				case 2:{fprintf(f2,"' "); mark = 1; s2++; break;}
            		  }}
    if ( mark == 1 ) { fprintf(f1,"%d ",a2); s1++; }
          	else { fprintf(f2,"%d ",a2); s2++;}
          	a1 = a2; fscanf(f,"%d",&a2);
        	}
        if ( s2 > 0 && mark == 2 ) { fprintf(f2,"'");}
        if ( s1 > 0 && mark == 1 ) { fprintf(f1,"'");}
        fclose(f2); fclose(f1); fclose(f);
        cout << endl;
        Print_File(name);
        Print_File("nmsort_1");
        Print_File("nmsort_2");
        cout << endl;
      f = fopen(name,"w");  f1 = fopen("nmsort_1","r");
        f2 = fopen("nmsort_2","r");
        if ( !feof(f1) ) fscanf(f1,"%d",&a1);
        if ( !feof(f2) ) fscanf(f2,"%d",&a2);
        bool file1, file2;
        while ( !feof(f1) && !feof(f2) ){	file1 = file2 = false;
          	while ( !file1 && !file2 ) {
            		if ( a1 <= a2 ) { fprintf(f,"%d ",a1); 
    				  file1 = End_Range(f1); fscanf(f1,"%d",&a1);	}
            else { fprintf(f,"%d ",a2); file2 = End_Range(f2);
              fscanf(f2,"%d",&a2);	}
          } 
    while ( !file1 ) {		fprintf(f,"%d ",a1);
            file1 = End_Range(f1);  fscanf(f1,"%d",&a1);	}
     while ( !file2 ) {	fprintf(f,"%d ",a2);  
    				file2 = End_Range(f2); fscanf(f2,"%d",&a2);	}
        }	file1 = file2 = false;
        while ( !file1 && !feof(f1) ) {	fprintf(f,"%d ",a1);
          		file1 = End_Range(f1); fscanf(f1,"%d",&a1);	}
        while ( !file2 && !feof(f2) ) {	fprintf(f,"%d ",a2);
          		file2 = End_Range(f2); fscanf(f2,"%d",&a2);	}
        fclose(f2); fclose(f1); fclose(f);
      }	 remove("nmsort_1");  remove("nmsort_2");
    }

    Потеряли пульт от телевизора? Найди его бинарным поиском!!!

    dethless, 19 Мая 2019

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

    +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
    namespace belugina
    {
    void Simple_Merging_Sort (char *name){ 
    	 int a1, a2, k, i, j, kol, tmp;  
    	FILE *f, *f1, *f2;  
    	kol = 0;  
    	if ( (f = fopen(name,"r")) == NULL )    
    		printf("\nИсходный файл не может быть прочитан...");  
    	else {    while ( !feof(f) ) {      
    		fscanf(f,"%d",&a1);      
    		kol++;    
    		}   
    	 fclose(f);  
    	} 
    k = 1;  
    while ( k < kol ){ 
    	f = fopen(name,"r");    
    	f1 = fopen("smsort_1","w");    
    	f2 = fopen("smsort_2","w");   
    	if ( !feof(f) ) fscanf(f,"%d",&a1);    
    	while ( !feof(f) ){     
    		 for ( i = 0; i < k && !feof(f) ; i++ ){        
    			fprintf(f1,"%d ",a1); fscanf(f,"%d",&a1); }      
    		for ( j = 0; j < k && !feof(f) ; j++ ){        
    			fprintf(f2,"%d ",a1);  fscanf(f,"%d",&a1);}   
    	 }   
    	 fclose(f2);    fclose(f1);    fclose(f); 
    f = fopen(name,"w");   f1 = fopen("smsort_1","r");    
    	f2 = fopen("smsort_2","r");    
    	if ( !feof(f1) ) fscanf(f1,"%d",&a1);   
    	if ( !feof(f2) ) fscanf(f2,"%d",&a2);    
    	while ( !feof(f1) && !feof(f2) ){     
    	 	i = 0;      j = 0;     
    	 	while ( i < k && j < k && !feof(f1) && !feof(f2) ) {        
    			if ( a1 < a2 ) {          
    			fprintf(f,"%d ",a1); fscanf(f1,"%d",&a1);i++;}        
    			else {          
    			fprintf(f,"%d ",a2);fscanf(f2,"%d",&a2); j++;}      
    	   	} 
    while ( i < k && !feof(f1) ) {        
    		     fprintf(f,"%d ",a1);  fscanf(f1,"%d",&a1); i++;}      
    		while ( j < k && !feof(f2) ) {        
    		     fprintf(f,"%d ",a2);   fscanf(f2,"%d",&a2);  j++;}   
     	 }    
    	while ( !feof(f1) ) {      
    		fprintf(f,"%d ",a1);      fscanf(f1,"%d",&a1);    }    
    	while ( !feof(f2) ) {      
    		fprintf(f,"%d ",a2);      fscanf(f2,"%d",&a2);    }   
    	fclose(f2);    fclose(f1);    fclose(f);    k *= 2;  
    	}  
    	remove("smsort_1");  remove("smsort_2");
    } 
    }

    Вектор это не динамический массив.

    dethless, 19 Мая 2019

    Комментарии (4)
  3. C++ / Говнокод #25611

    +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
    void Merging_Sort (int n, int *x){
    	int i, j, k, t, s, Fin1, Fin2;
    	int* tmp = new int[n];
    	k = 1;
    	while (k < n){
    		 t = 0;    s = 0;
    		while (t+k < n){
    			Fin1 = t+k;
    			Fin2 = (t+2*k < n ? t+2*k : n);
    			i = t;       j = Fin1;
                for ( ; i < Fin1 && j < Fin2 ; s++){
    				if (x[i] < x[j]) {
    					tmp[s] = x[i];          i++;
    				}        else {
    				 	tmp[s] = x[j];          j++;
    			 	}
    		 	}
    			for ( ; i < Fin1; i++, s++)       tmp[s] = x[i];
    			for ( ; j < Fin2; j++, s++)       tmp[s] = x[j];
    			t = Fin2;
    	 	}   k *= 2;
    	 	for (s = 0; s < t; s++)      x[s] = tmp[s];
    	}
    	delete(tmp);
    }

    Это новый вид искусство?

    dethless, 19 Мая 2019

    Комментарии (1)
  4. C++ / Говнокод #25610

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    namespace belugina
    {
    void Hoar_Sort (int k, int *x){
    	Quick_Sort (0, k-1, x);}
    }

    Как вы думаете это новая форма рекурсии?

    dethless, 19 Мая 2019

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

    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
    namespace belugina
    {
        void Exchange (int i, int j, int *x){ 
    	int tmp;
    	tmp = x[i];
    	x[i] = x[j];
    	x[j] = tmp;
    }
    
    void sifting (int left, int right, int *x){
    	int q, p, h;
    	q=2*left+1;
    	p=q+1;
    	if (q <= right){
    		if (p <= right && x[p] > x[q])
    			q = p;
    		if (x[left] < x[q]){
    			 Exchange (left, q, x);
    			 sifting(q, right, x);
    			 }
    		 }
    }
        
    }

    Бред сумасшедшего. По утверждению автора алгоритм "Просеивание" элементов.

    dethless, 19 Мая 2019

    Комментарии (52)
  6. JavaScript / Говнокод #25608

    +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
    /* ... */
      if  (kindmusic64[7].checked == true)
      {
        var number = Math.floor(Math.random() * 41);
        switch(number)
        {
          case 0: redradio[0].checked = true; greenradio[0].checked = true; blueradio[1].checked = true;  break;
          case 1: redradio[0].checked = true; greenradio[1].checked = true; blueradio[0].checked = true;  break;
          case 2: redradio[0].checked = true; greenradio[1].checked = true; blueradio[1].checked = true;  break;
          case 3: redradio[1].checked = true; greenradio[0].checked = true; blueradio[0].checked = true;  break;
          case 4: redradio[1].checked = true; greenradio[0].checked = true; blueradio[1].checked = true;  break;
          case 5: redradio[1].checked = true; greenradio[1].checked = true; blueradio[0].checked = true;  break;
          case 6: redradio[1].checked = true; greenradio[1].checked = true; blueradio[2].checked = true;  break;
          case 7: redradio[1].checked = true; greenradio[2].checked = true; blueradio[1].checked = true;  break;
          case 8: redradio[1].checked = true; greenradio[2].checked = true; blueradio[2].checked = true;  break;
          case 9: redradio[2].checked = true; greenradio[1].checked = true; blueradio[1].checked = true;  break;
          case 10: redradio[2].checked = true; greenradio[1].checked = true; blueradio[2].checked = true;  break;
          case 11: redradio[2].checked = true; greenradio[2].checked = true; blueradio[1].checked = true;  break;
          case 12: redradio[2].checked = true; greenradio[2].checked = true; blueradio[3].checked = true;  break;
          case 13: redradio[2].checked = true; greenradio[3].checked = true; blueradio[2].checked = true;  break;
          case 14: redradio[2].checked = true; greenradio[3].checked = true; blueradio[3].checked = true;  break;
          case 15: redradio[3].checked = true; greenradio[2].checked = true; blueradio[2].checked = true;  break;
          case 16: redradio[3].checked = true; greenradio[2].checked = true; blueradio[3].checked = true;  break;
          case 17: redradio[3].checked = true; greenradio[3].checked = true; blueradio[2].checked = true;  break;
          case 18: redradio[0].checked = true; greenradio[0].checked = true; blueradio[2].checked = true;  break;
          case 19: redradio[0].checked = true; greenradio[2].checked = true; blueradio[0].checked = true;  break;
          case 20: redradio[0].checked = true; greenradio[2].checked = true; blueradio[1].checked = true;  break;
          case 21: redradio[1].checked = true; greenradio[0].checked = true; blueradio[2].checked = true;  break;
          case 22: redradio[1].checked = true; greenradio[1].checked = true; blueradio[3].checked = true;  break;
          case 23: redradio[1].checked = true; greenradio[3].checked = true; blueradio[1].checked = true;  break;
          case 24: redradio[1].checked = true; greenradio[3].checked = true; blueradio[2].checked = true;  break;
          case 25: redradio[2].checked = true; greenradio[0].checked = true; blueradio[0].checked = true;  break;
          case 26: redradio[2].checked = true; greenradio[1].checked = true; blueradio[0].checked = true;  break;
          case 27: redradio[2].checked = true; greenradio[1].checked = true; blueradio[3].checked = true;  break;
          case 28: redradio[3].checked = true; greenradio[1].checked = true; blueradio[1].checked = true;  break;
          case 29: redradio[3].checked = true; greenradio[2].checked = true; blueradio[1].checked = true;  break;
          case 30: redradio[0].checked = true; greenradio[0].checked = true; blueradio[0].checked = true;  break;
          case 31: redradio[1].checked = true; greenradio[1].checked = true; blueradio[1].checked = true;  break;
          case 32: redradio[2].checked = true; greenradio[2].checked = true; blueradio[2].checked = true;  break;
          case 33: redradio[3].checked = true; greenradio[3].checked = true; blueradio[3].checked = true;  break;
          case 34: redradio[0].checked = true; greenradio[3].checked = true; blueradio[2].checked = true;  break;
          case 35: redradio[0].checked = true; greenradio[2].checked = true; blueradio[2].checked = true;  break;
          case 36: redradio[1].checked = true; greenradio[3].checked = true; blueradio[3].checked = true;  break;
          case 37: redradio[2].checked = true; greenradio[0].checked = true; blueradio[2].checked = true;  break;
          case 38: redradio[3].checked = true; greenradio[1].checked = true; blueradio[3].checked = true;  break;
          case 39: redradio[2].checked = true; greenradio[2].checked = true; blueradio[0].checked = true;  break;
          case 40: redradio[3].checked = true; greenradio[3].checked = true; blueradio[1].checked = true;  break;
          case 41: redradio[2].checked = true; greenradio[0].checked = true; blueradio[3].checked = true;  break;
          case 42: redradio[0].checked = true; greenradio[1].checked = true; blueradio[2].checked = true;  break;
          case 43: redradio[1].checked = true; greenradio[2].checked = true; blueradio[3].checked = true;  break;
          case 44: redradio[0].checked = true; greenradio[3].checked = true; blueradio[1].checked = true;  break;
          case 45: redradio[1].checked = true; greenradio[0].checked = true; blueradio[3].checked = true;  break;
          case 46: redradio[1].checked = true; greenradio[2].checked = true; blueradio[0].checked = true;  break;
          case 47: redradio[2].checked = true; greenradio[3].checked = true; blueradio[1].checked = true;  break;
          case 48: redradio[2].checked = true; greenradio[0].checked = true; blueradio[1].checked = true;  break;
          case 49: redradio[3].checked = true; greenradio[1].checked = true; blueradio[2].checked = true;  break;
          case 48: redradio[3].checked = true; greenradio[1].checked = true; blueradio[0].checked = true;  break;
          case 49: redradio[3].checked = true; greenradio[2].checked = true; blueradio[0].checked = true;  break;
    /* ... */

    https://olgusha.ru/javascript/colors.htm, да ещё написано, что попробуйте протестировать способность вашего компьютера сочинять музыку и выбирать случайным образом цвета.

    unicorn, 18 Мая 2019

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

    +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
    <?php
    /**
     * $URL: svn://svn.subversion.ru/usr/local/svn/mzz/trunk/system/forms/validators/formHostnameRule.php $
     *
     * MZZ Content Management System (c) 2005-2007
     * Website : http://www.mzz.ru
     *
     * This program is free software and released under
     * the GNU/GPL License (See /docs/GPL.txt).
     *
     * @link http://www.mzz.ru
     * @version $Id: formHostnameRule.php 3864 2009-10-21 04:50:04Z zerkms $
     */
    /**
     * formHostnameRule: правило, проверяющее имя хоста
     *
     * @package system
     * @subpackage forms
     * @version 0.1.1
     */
    class formHostnameRule extends formAbstractRule
    {
        private $validTlds = array(
        'ac', 'ad', 'ae', 'aero', 'af', 'ag', 'ai', 'al', 'am', 'an', 'ao',
        'aq', 'ar', 'arpa', 'as', 'at', 'au', 'aw', 'ax', 'az', 'ba', 'bb',
        'bd', 'be', 'bf', 'bg', 'bh', 'bi', 'biz', 'bj', 'bm', 'bn', 'bo',
        'br', 'bs', 'bt', 'bv', 'bw', 'by', 'bz', 'ca', 'cat', 'cc', 'cd',
        'cf', 'cg', 'ch', 'ci', 'ck', 'cl', 'cm', 'cn', 'co', 'com', 'coop',
        'cr', 'cu', 'cv', 'cx', 'cy', 'cz', 'de', 'dj', 'dk', 'dm', 'do',
        'dz', 'ec', 'edu', 'ee', 'eg', 'er', 'es', 'et', 'eu', 'fi', 'fj',
        'fk', 'fm', 'fo', 'fr', 'ga', 'gb', 'gd', 'ge', 'gf', 'gg', 'gh',
        'gi', 'gl', 'gm', 'gn', 'gov', 'gp', 'gq', 'gr', 'gs', 'gt', 'gu',
        'gw', 'gy', 'hk', 'hm', 'hn', 'hr', 'ht', 'hu', 'id', 'ie', 'il',
        'im', 'in', 'info', 'int', 'io', 'iq', 'ir', 'is', 'it', 'je', 'jm',
        'jo', 'jobs', 'jp', 'ke', 'kg', 'kh', 'ki', 'km', 'kn', 'kr', 'kw',
        'ky', 'kz', 'la', 'lb', 'lc', 'li', 'lk', 'lr', 'ls', 'lt', 'lu',
        'lv', 'ly', 'ma', 'mc', 'md', 'me', 'mg', 'mh', 'mil', 'mk', 'ml', 'mm',
        'mn', 'mo', 'mobi', 'mp', 'mq', 'mr', 'ms', 'mt', 'mu', 'museum', 'mv',
        'mw', 'mx', 'my', 'mz', 'na', 'name', 'nc', 'ne', 'net', 'nf', 'ng',
        'ni', 'nl', 'no', 'np', 'nr', 'nu', 'nz', 'om', 'org', 'pa', 'pe',
        'pf', 'pg', 'ph', 'pk', 'pl', 'pm', 'pn', 'pr', 'pro', 'ps', 'pt',
        'pw', 'py', 'qa', 're', 'ro', 'ru', 'rw', 'sa', 'sb', 'sc', 'sd',
        'se', 'sg', 'sh', 'si', 'sj', 'sk', 'sl', 'sm', 'sn', 'so', 'sr',
        'st', 'su', 'sv', 'sy', 'sz', 'tc', 'td', 'tf', 'tg', 'th', 'tj',
        'tk', 'tl', 'tm', 'tn', 'to', 'tp', 'tr', 'travel', 'tt', 'tv', 'tw',
        'tz', 'ua', 'ug', 'uk', 'um', 'us', 'uy', 'uz', 'va', 'vc', 've',
        'vg', 'vi', 'vn', 'vu', 'wf', 'ws', 'ye', 'yt', 'yu', 'za', 'zm',
        'zw'
        );
        protected function _validate($value)
        {
            if (preg_match('#^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$#', $value)) {
                return true;
            }
            $domainParts = explode('.', $value);
            if (sizeof($domainParts) < 2) {
                return false;
            }
            if (strlen($value) > 254 || strlen($value) < 4) {
                return false;
            }
            $tld = array_pop($domainParts);
            if (!in_array(strtolower($tld), $this->validTlds)) {
                return false;
            }
            $validChars = 'a-z0-9\-';
            foreach ($domainParts as $part) {
                if (strpos($part, '-') === 0 || (strlen($part) > 3 && strpos($part, '--', 2) === 2) || substr($part, -1) === '-') {
                    return false;
                }
                if (!preg_match('#^[' . $validChars . ']{1,63}$#i', $part)) {
                    return false;
                }
            }
            return true;
        }
    }
    ?>

    Домены валидировали-валидировали, да недовалидировали.

    https://github.com/wiistriker/govnokod_legacy/blob/master/mzz/system/forms/validators/formHostnameRule.php

    gost, 17 Мая 2019

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

    +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
    <?php 
    $css_fold = 'css/';
    $js_fold = 'js/';
    $css_files= scandir($css_fold);
    $js_files= scandir($js_fold);
    
    foreach ($js_files as $js_file) {
    	if(preg_match('/\.(js)/', $js_file)){
    		if (substr($js_file, -3)==".js") {
    			echo'<script src="js/'.$js_file.'"></script>'.PHP_EOL;
    		}
    	}
    }
    
    foreach ($css_files as $css_file) {
    	if(preg_match('/\.(css)/', $css_file)){
    		if (substr($css_file, -4)==".css") {
    			echo'<link rel="stylesheet" type="text/css" href="css/'.$css_file.'">'.PHP_EOL;
    		}
    	}
    }
    ?>

    Подтягиваем все из css и js

    ZombiePm, 17 Мая 2019

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

    −102

    1. 1
    Всё. Петухи закончились. Всем спасибо, все свободны.

    nocJlegHuu_nemyx, 16 Мая 2019

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

    +4

    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
    &НаКлиенте
    Процедура Расчитать(Команда)
    	ТекДата = ТекущаяДата();
    	ТекМесяц = Месяц(ТекДата);
    	МесяцРождения = Месяц(ДатаРождения);
    
    	
    	Если ТекМесяц=МесяцРождения Тогда       //День рождения сегодня или в этом месяце,
    	    Если День(ТекДата)=День(ДатаРождения) Тогда
    		
    			КоличествоДнейДоДР = 0;
    		ИначеЕсли День(ТекДата)<День(ДатаРождения)  Тогда 
    			КоличествоДнейДоДР = День(ДатаРождения)-День(ТекДата);
    		Иначе
    			
    			
    		  КоличествоДнейДоДР = День(КонецМесяца(ТекДата))-День(ТекДата);
    		 Дата = ДобавитьМесяц(ТекДата,1);
    		 Ограничитель = (12-ТекМесяц)+МесяцРождения;
    		 Для сч=1 По Ограничитель Цикл
    			Если сч=Ограничитель Тогда			
    			    КоличествоДнейДоДР = КоличествоДнейДоДР+День(ДатаРождения);
    			    продолжить;			
    			КонецЕсли; 
    
    			КоличествоДнейДоДР = КоличествоДнейДоДР+День(КонецМесяца(Дата)) ;
    			 Дата = ДобавитьМесяц(Дата,1);
    		 	
    		 
    		 КонецЦикла; 
    		
    		КонецЕсли; 
    		
    	
    	ИначеЕсли ТекМесяц<МесяцРождения Тогда   //День рождения еще не наступил,
    		 КоличествоДнейДоДР = День(КонецМесяца(ТекДата))-День(ТекДата);
    		 Дата = ДобавитьМесяц(ТекДата,1);
    		 Для сч= ТекМесяц+1 По МесяцРождения Цикл
    			
                            Если сч=МесяцРождения Тогда
    			   КоличествоДнейДоДР = КоличествоДнейДоДР+День(ДатаРождения);
    			   продолжить;
    			КонецЕсли; 
    
    			КоличествоДнейДоДР = КоличествоДнейДоДР+День(КонецМесяца(Дата)) ;
    			 Дата = ДобавитьМесяц(Дата,1);
    		 	
    		 
    		 КонецЦикла; 
    		
    		
    	ИначеЕсли ТекМесяц>МесяцРождения Тогда     //День рождения уже прошел.	
    		     КоличествоДнейДоДР = День(КонецМесяца(ТекДата))-День(ТекДата);
    		 Дата = ДобавитьМесяц(ТекДата,1);
    		 Ограничитель = (12-ТекМесяц)+МесяцРождения;
    		 Для сч= 1 По Ограничитель Цикл
    
    			Если сч=Ограничитель Тогда
    			  КоличествоДнейДоДР = КоличествоДнейДоДР+День(ДатаРождения);
    			  продолжить;
    			КонецЕсли;
     
    			КоличествоДнейДоДР = КоличествоДнейДоДР+День(КонецМесяца(Дата)) ;
    			 Дата = ДобавитьМесяц(Дата,1);
    		 	
    		 
    		 КонецЦикла; 
    	
    	 КонецЕсли; 
    	 
    	 Сообщение = Новый СообщениеПользователю;
    	 Сообщение.Текст = КоличествоДнейДоДР;
    	 Сообщение.Сообщить(); 
    		
    	// Вставить содержимое обработчика.
    КонецПроцедуры

    Задача рассчитать количество дней до дня рождения, вопрос в том что не много ли я использовал условий Если?

    rusin_av, 16 Мая 2019

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