#include "cielib.h" int main() { int D = podajD(); int K = podajK(); int R = podajR(); int top[501]; int bottom[501]; int middle[501]; for (int i = 0; i < D; i++) { top[i] = 0; bottom[i] = R; middle[i] = R / 2; } int currentSize = R + 1; while (currentSize > 1) { if (currentSize == 3) { currentSize = 1; } else { currentSize = currentSize / 2 + 1; } for (int i = 0; i < D; i++) { int currentTop = top[i]; int currentBottom = bottom[i]; int currentMiddle = middle[i]; middle[i] = currentBottom; czyCieplo(middle); middle[i] = currentTop; bool isTopHoter = czyCieplo(middle); middle[i] = currentBottom; bool isBottomHoter = czyCieplo(middle); if (isTopHoter) { bottom[i] = top[i] + currentSize - 1; } else if (isBottomHoter) { top[i] = bottom[i] - currentSize + 1; } else { top[i] = currentMiddle; bottom[i] = top[i] + currentSize - 1; } middle[i] = top[i] + (bottom[i] - top[i]) / 2; } } znalazlem(top); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | #include "cielib.h" int main() { int D = podajD(); int K = podajK(); int R = podajR(); int top[501]; int bottom[501]; int middle[501]; for (int i = 0; i < D; i++) { top[i] = 0; bottom[i] = R; middle[i] = R / 2; } int currentSize = R + 1; while (currentSize > 1) { if (currentSize == 3) { currentSize = 1; } else { currentSize = currentSize / 2 + 1; } for (int i = 0; i < D; i++) { int currentTop = top[i]; int currentBottom = bottom[i]; int currentMiddle = middle[i]; middle[i] = currentBottom; czyCieplo(middle); middle[i] = currentTop; bool isTopHoter = czyCieplo(middle); middle[i] = currentBottom; bool isBottomHoter = czyCieplo(middle); if (isTopHoter) { bottom[i] = top[i] + currentSize - 1; } else if (isBottomHoter) { top[i] = bottom[i] - currentSize + 1; } else { top[i] = currentMiddle; bottom[i] = top[i] + currentSize - 1; } middle[i] = top[i] + (bottom[i] - top[i]) / 2; } } znalazlem(top); return 0; } |