Untitled
unknown
plain_text
3 years ago
2.0 kB
4
Indexable
// Name Surname = Hakkı Kokur // No = 150120033 #include <stdio.h> int starterPoints(int starterPoint, int index, int height){ int nextStartPoint = starterPoint + 62*height; int nextEndPoint = starterPoint + 64*height; if (checkRow(starterPoint,index,height,0)) return 1; if(nextEndPoint > 2016) return 0; return starterPoints(nextStartPoint, index,height) || starterPoints(nextEndPoint, index,height); } int checkRow(int starterPoint, int index, int height, int count){ if ( count < height ){ int starterIndex = starterPoint + 62*count; int endIndex = starterPoint + 64*count++; int result = checkEachPoint(starterIndex, endIndex, index); if ( result == 1 ){ return 1; } if( starterIndex == starterPoint + 62*(height-1)) return 0; return checkRow(starterPoint, index, height,count); } else return 0; } int checkEachPoint(int starterIndex, int endIndex, int index){ if ( starterIndex == index) return 1; else if ( starterIndex == endIndex) return 0; else { starterIndex +=1; checkEachPoint(starterIndex, endIndex, index); } } int takingPower(int number, int power, int control){ number *= control; power -=1; if ( power > 1) takingPower(number, power, control); else return number; } int takePower(int number, int power){ return takingPower(number,power,number); } void main(){ int height; int input; printf("Please enter the number from 0 to 4: "); scanf("%d", &input); height = takePower(2, 5-input); print(height, 1); } // count must be 1 in begining void print(int height,int count){ int bool0 = starterPoints(32,count,height); if(bool0) printf("1"); else printf("_"); if (count % 63 == 0) printf("\n"); count++; if (count <= 2016) print(height, count); }
Editor is loading...