Task: | Ratsun reitit |
Sender: | motsgar |
Submission time: | 2020-10-03 11:25:14 +0300 |
Language: | C++ (C++17) |
Status: | COMPILE ERROR |
Compiler report
input/code.cpp:1:0: warning: ignoring #pragma warning [-Wunknown-pragmas] #pragma warning(disable: 4996) input/code.cpp: In function 'int main()': input/code.cpp:73:27: error: 'log10' was not declared in this scope if (i != 0) numLength = log10(outputInt[i]) + 1; ^~~~~ input/code.cpp:76:3: error: 'itoa' was not declared in this scope itoa(outputInt[i], output, 10); ^~~~ input/code.cpp:76:3: note: suggested alternative: 'atol' itoa(outputInt[i], output, 10); ^~~~ atol input/code.cpp:82:3: warning: value computed is not used [-Wunused-value] *output++; ^~~~~~~~~ input/code.cpp:83:3: warning: value computed is not used [-Wunused-value] *output++; ^~~~~~~~~ input/code.cpp:84:3: warning: value computed is not used [-Wunused-value] *output++; ^~~~~~~~~ input/code.cpp:89:3: warning: value computed is not used [-Wunused-value] *output--; ^~~~~~~~~ input/code.cpp:90:3: warning: value computed is not used [-Wunused-...
Code
#pragma warning(disable: 4996) #include <iostream> #define maxSize 100 using namespace std; char input[10]; char* output = new char[maxSize * maxSize * 3]; int outputInt[maxSize * maxSize]; int outputIntIndex = 0; int main() { cin.getline(input, sizeof(input)); int boardSize = 0; int j = 0; while (input[j] != '\0') { boardSize = boardSize * 10 + (input[j] - 48); j++; } int cellValue; for (int y = 0; y < boardSize; y++) { int startValue; int height = 0; if (y > 3) { startValue = y - (y / 4) * 2; height = (y - 4) / 2 + y % 2 * 2 + 4; } int shouldGrow = (y / 2) % 2; for (int x = 0; x <= y; x++) { if (y > 3 && x < height) { if (shouldGrow == 0) cellValue = startValue + x % 2; else cellValue = startValue - x % 2; } else if (x == y) cellValue = ((x - 1) / 3) * 2 + 2; else if (y > 3 && x >= height && x < y) { if (y % 2 == 1) cellValue = x - ((x - height + 2) / 3) * 2 - 1; else cellValue = x - ((x - height + 2) / 3) * 2; } outputInt[y * boardSize + x] = cellValue; if (x != y) outputInt[x * boardSize + y] = cellValue; } } outputInt[0] = 0; outputInt[1] = 3; if (boardSize == 4) { outputInt[3] = 5; outputInt[3 * boardSize] = 5; } else { outputInt[3] = 3; outputInt[3 * boardSize] = 3; } outputInt[1 * boardSize + 0] = 3; outputInt[1 * boardSize + 1] = 4; outputInt[1 * boardSize + 2] = 1; outputInt[2 * boardSize + 1] = 1; outputInt[2 * boardSize + 2] = 4; outputInt[2 * boardSize + 3] = 3; outputInt[3 * boardSize + 2] = 3; for (int i = 0; i < boardSize * boardSize; i++) { int numLength; if (i != 0) numLength = log10(outputInt[i]) + 1; else numLength = 1; itoa(outputInt[i], output, 10); output[numLength] = ' '; if ((i + 1) % boardSize == 0) output[2] = '\n'; else output[2] = ' '; *output++; *output++; *output++; } output[-1] = '\0'; for (int i = 0; i < boardSize * boardSize; i++) { *output--; *output--; *output--; } printf("%s", output); exit(0); }