1. C++ / Говнокод #13662

    +11

    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
    for(int i = posX-width, numBlock = 0; i < posX+width; i++)
        {
            for(int j = posY-height; j < posY+height; j++)
            {
            if(worldInfo[i][j] != air){
                switch(worldInfo[i][j])
                {
                case grass:
                    for(i = 0; i < 8; i++) tempCoord[numBlock*8+i] = texCoordList[0][i];
                break;
                case dirt:
                    for(i = 0; i < 8; i++) tempCoord[numBlock*8+i] = texCoordList[1][i];
                break;
                case rock:
                    for(i = 0; i < 8; i++) tempCoord[numBlock*8+i] = texCoordList[2][i];
                break;
                case water:
                    if(j != 35)
                    for(i = 0; i < 8; i++) tempCoord[numBlock*8+i] = texCoordList[3][i];
                    else
                    for(i = 0; i < 8; i++) tempCoord[numBlock*8+i] = texCoordList[4][i];
                break;
                case sand:
                    for(i = 0; i < 8; i++) tempCoord[numBlock*8+i] = texCoordList[5][i];
                break;
                }
                numBlock++;
                }
            }
        }

    Мое. Долго искал причину краша. Нашел. Если в кратце, тот тут идет присваивание текстурных коррдинат. Я оставлю это здесь, приятного аппетита!

    pelmenka, 24 Августа 2013

    Комментарии (32)
  2. Java / Говнокод #13661

    +64

    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
    import java.util.ArrayList;
    
    public class Chapter19 {
    	/* find repeat chars in text (in all words of text)
    	 * print repeat chars
    	 * 
    	 */
    	private String stringArray[] = { "Allocates ae neaw Setringa tehat",
    			"represeants tahe same saequence " };
    			
    	final private String alfabetArray = "abcdefghijklmnopqrstuvwxyz"; 
    	private ArrayList <Character> repeatChars; 
    
    	public void run() {
    		
    		printStringArray();			
    		
    		repeatChars = new ArrayList<Character>();
    		extractRepeatChars();
    		
    		if (!repeatChars.isEmpty()) {
    			printRepeatChars();
    		} else {
    			System.out.println("not repeat ");
    		}
    	}
    	
    	private void printRepeatChars(){
    		System.out.println("");
    		for (char c : repeatChars) {
    			System.out.println(c);
    		}	
    	}
    	
    	private void printStringArray(){
    		System.out.println(" ");
    		for (String s : stringArray) {
    			System.out.println(s);
    		}	
    	}
    	
    	
    	public String [][] parseStringArray() {
    		String wordsArray[][] = new String[stringArray.length][]; 
    		for (int i = 0; i < wordsArray.length; i++) {
    			wordsArray[i] = stringArray[i].split("\n|\t| "); 
    		}
    		
    		return wordsArray;
    	}
    
    	
    	public int findRepeatCharInWordsArray(String [][]wordsArray, char c) {		 													
    		for (int i = 0; i < wordsArray.length; i++) { 										
    			for (int j = 0; j < wordsArray[i].length; j++) { 			
    				if (wordsArray[i][j].indexOf(c) < 0) { 
    					return 0; // zodyje c nerastas
    				}
    			}	
    		}
    
    		return 1;
    	}
    
    
    	public void extractRepeatChars() {
    		String wordsArray[][] = parseStringArray();	
    		for (char c : alfabetArray.toCharArray()) {
    			if (findRepeatCharInWordsArray(wordsArray, c) > 0) {
    				repeatChars.add(c);
    			}
    		}
    	}
    
    } // end

    chapter 19

    spivti, 24 Августа 2013

    Комментарии (121)
  3. Java / Говнокод #13660

    +64

    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
    import java.util.ArrayList;
    import java.util.LinkedList;
    import java.util.Scanner;
    
    public class Chapter4 {
    	/*
    	 * find minimal difference symbols words in line; if words count > 0, print
    	 * first word;
    	 */
    	public LinkedList<String> wordsList = new LinkedList<>();
    	public ArrayList<String> minUniqueSimbolWords = new ArrayList<String>();
    	final int wordsCount = 3; 
    
    	public void run() {
    
    		System.out.println("Iveskite " + wordsCount + " zodzius: ");
    		Scanner scan = new Scanner(System.in);
    		for (int i = 0; i < wordsCount; i++) {
    			wordsList.add(scan.nextLine());
    		}
    
    		scan.close();
    
    		addMinUniqueSimbolCountWordsToList();
    		if (minUniqueSimbolWords.isEmpty()) {
    			System.out.println("not unique words");
    			return;
    		}
    
    		printUniqueSimbolWords();
    
    	}
    
    	private void printUniqueSimbolWords() {
    		System.out
    				.println("");
    		for (String s : minUniqueSimbolWords) {
    			System.out.println(s);
    		}
    	}
    
    	private void addMinUniqueSimbolCountWordsToList() {
    		for (String word : wordsList) {			
    			if (minUniqueSimbolWords.isEmpty()) { 
    				minUniqueSimbolWords.add(word); 
    			} else {
    				int count = getUniqueSimbolCount(word.toCharArray());
    				addMinUniqueSimbolsCountWord(word, count);
    			}
    		}
    	}
    
    	
    	private void addMinUniqueSimbolsCountWord(String word, int count) {
    		int countOfFirstFromList = getUniqueSimbolCount(wordsList.getFirst()
    				.toCharArray());
    		if (count < countOfFirstFromList) {
    			minUniqueSimbolWords.clear();
    			minUniqueSimbolWords.add(word);
    
    		} else if (count == countOfFirstFromList) {
    			minUniqueSimbolWords.add(word); 
    		}
    
    	}
    
    	
    	private int getUniqueSimbolCount(char[] str) {
    		ArrayList<Character> lst = new ArrayList<Character>();
    		for (char c : str) {
    			if (!lst.contains(c)) { 
    				lst.add(c);
    			}
    		}
    
    		return lst.size();
    	}
    
    } // end class

    еще одно задание

    spivti, 24 Августа 2013

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

    +65

    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
    /*
     * 
     * 
     */
    
    public class Chapter1 {
    	private String text[] = { "Returns a  new string that is a ",
    			"substring of this string" };
    	private String splitted[];
    
    	private int k = 2; // 
    	private char c = '<'; 
    
    	public void run() {
    		for (int i = 0; i < text.length; i++) {
    			text[i] = makeString(text[i], change(i)); 
    														
    			System.out.println(text[i]);
    			
    		}
    	}
    
    	/*
    	 * 
    	 */
    	private String makeString(String textLine, String[] changed) {
    		StringBuilder sBui = new StringBuilder(textLine);
    
    		int i = 0; // changed index
    		int beginIndex = 0; 
    		
    
    		for (int j = 0; j < splitted.length; j++) {
    			beginIndex = sBui.indexOf(splitted[j], beginIndex); // word begin		
    			int endIndex = beginIndex + splitted[j].length(); // word end
    			
    			if(splitted[j].length() > k){			
    				sBui.delete(beginIndex, endIndex);
    				sBui.insert(beginIndex, changed[i++]);
    			} 
    			
    			beginIndex = endIndex;
    		}
    						
    		return sBui.toString();
    	}
    
    	/*
    	 * 
    	 * 
    	 */
    	public String[] change(int i) {
    
    		splitted = text[i].split("\t|\n| "); 
    
    		for (int indx = 0; indx < splitted.length; indx++) {
    			if (splitted[indx].length() > k) {
    				StringBuilder sBuild = new StringBuilder(splitted[indx]);
    				sBuild.setCharAt(k, c);
    				splitted[indx] = sBuild.toString(); // irasomas pakeistas zodis				
    			}
    		}
    
    		return splitted;
    	}
    
    } // end

    help, задание - вкаждом слове текста к-тую буквы заменить с символом, если длина слова меньше к, замену не выполнять.

    Exception in thread "main" java.lang.StringIndexOutOfBoundsExceptio n: String index out of range: -1 (проблема)

    spivti, 24 Августа 2013

    Комментарии (104)
  5. Objective C / Говнокод #13657

    −114

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    - (void)setHidden:(BOOL)newHidden
    {
        [super setHidden:newHidden];
        if (newHidden){
            [m_bannerViewController hideBanner];
            return;
        }
        
        [self reload];
    }

    ZevsVU, 23 Августа 2013

    Комментарии (2)
  6. C++ / Говнокод #13656

    +16

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    void setEnabled(bool enabled)
    {
        super.setEnabled(enabled)
        if (enabled) {
            objectsArray.disable();
            return;
        }
        enable();
    }

    ZevsVU, 23 Августа 2013

    Комментарии (33)
  7. JavaScript / Говнокод #13655

    +141

    1. 1
    for (; b < d; b++)

    subj

    Stealth, 23 Августа 2013

    Комментарии (14)
  8. JavaScript / Говнокод #13654

    +144

    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
    <body style=margin:0 
    
    onload="for( 
    
    s=window.screen, 
    w=q.width=s.width, 
    h=q.height=s.height, 
    m=Math.random, 
    p=[], 
    i=0; i<256; 
    
    p[i++]=1 );
    
    setInterval('9Style=\'rgba(0,0,0,.05)\'9Rect(0,0,w,h)9Style=\'#0F0\';
    
    p.map(function(v,i){9Text(String.fromCharCode(3e4+m()*33),i*10,v);
    p[i]=v>758+m()*1e4?0:v+10})'.split(9).join(';q.getContext(\'2d\').fill'),33)">
    
    
    <canvas id=q>

    Найди утечку ( many many times i jerk -> ctx ;)

    Stealth, 23 Августа 2013

    Комментарии (1)
  9. Objective C / Говнокод #13653

    −126

    1. 1
    NSDictionary *d =  [NSDictionary dictionaryWithObjectsAndKeys:@(NO?1:2), @"EVENT_VISIBILITY"];

    mas_an, 23 Августа 2013

    Комментарии (2)
  10. Pascal / Говнокод #13652

    +136

    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
    begin
    if(TimerVremya.Enabled = True) then
      begin
        if(CheckBox1.Checked = False) then
        begin
        Bass_channelPlay(Channel, false);
        Panel1.Caption := 'Playing';
        TimerFraza.Enabled := False;
        end
        else
        begin
         Bass_channelPlay(Privlek, false);
         Timer2.Enabled := True;
         TimerFraza.Enabled := False;
        end;
    end;

    А не ударить ли нам по басам? Вот только запашок не к месту, с чего бы такая оказия?..

    Stertor, 23 Августа 2013

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