Creating new bugs

This commit is contained in:
Aelita4 2020-12-17 00:48:03 +01:00
parent 7a7ff726b5
commit 415e1ecd6f
1 changed files with 164 additions and 11 deletions

175
main.cpp
View File

@ -130,8 +130,8 @@ bool checkChar(char c, int type)
void heapPointer(int y)
{
gotoxy(0, 0);
std::cout << y;
/*gotoxy(0, 0);
std::cout << y;*/
char t = '\0';
if(y > 0)
@ -185,11 +185,35 @@ void heapPointer(int y)
for(int i = 0; i <= 10; i++) std::cout << " ";
}
void displayNumBuilder(int n)
{
int len;
int i = n;
for(len = 0; i > 0; len++)
{
i /= 10;
}
//std::cout << 10 - len;
gotoxy(2, 2);
color(RED, BLACK);
std::cout << n;
for(int j = 0; j < (10 - len); j++)
{
std::cout << " ";
}
color(WHITE, BLACK);
}
std::string stringToONP(std::string s, int speed = 500)
{
heapPointer(0);
std::string out = "";
int len = s.length();
int numBuild = 0;
int numBuildCount = 1;
char tmp;
char heap[100] {};
@ -205,6 +229,11 @@ std::string stringToONP(std::string s, int speed = 500)
switch (tmp)
{
case '=':
numBuildCount = 1;
out += std::to_string(numBuild);
numBuild = 0;
out += ";";
displayNumBuilder(0);
for (; counter > 0; counter--)
{
out += heap[counter - 1];
@ -236,12 +265,21 @@ std::string stringToONP(std::string s, int speed = 500)
case '7':
case '8':
case '9':
out += tmp;
numBuild += (numBuildCount * (tmp - '0'));
numBuildCount *= 10;
displayNumBuilder(numBuild);
//out += tmp;
break;
case '+':
case '-':
case '*':
case '/':
numBuildCount = 1;
out += std::to_string(numBuild);
numBuild = 0;
out += ";";
displayNumBuilder(0);
while (counter)
{
if (priority(tmp) > priority(heap[counter - 1])) break;
@ -325,10 +363,13 @@ int calculateONP(std::string s, int speed = 500)
{
heapPointer(0);
int out = 0;
int numBuild = 0;
int numBuildCount = 1;
int len = s.length();
char tmp;
int counter = 0;
int calculate = 0;
int digit = 0;
int heap[100]{};
for (int i = 0; i < 100; i++) heap[i] = 0;
@ -336,11 +377,39 @@ int calculateONP(std::string s, int speed = 500)
for (int i = 0; i < len; i++)
{
//gotoxy(1 + i, 8);
color(LIGHT_GREEN, BLACK);
gotoxy(41 + i, 4);
std::cout << " ^";
tmp = s.c_str()[i];
switch (tmp)
{
case ';':
heap[counter] = numBuild;
//gotoxy(3 + (2 * counter), 2);
gotoxy(42 + i, 3);
color(LIGHT_GREEN, BLACK);
//std::cout << numBuild;
gotoxy(41 + i, 4);
std::cout << " ^";
color(WHITE, BLACK);
counter++;
heapPointer(counter);
gotoxy(2, 3 + counter);
color(YELLOW, BLACK);
std::cout << numBuild;
numBuildCount = 1;
numBuild = 0;
displayNumBuilder(0);
gotoxy(42 + i, 3);
color(LIGHT_GREEN, BLACK);
std::cout << tmp;
gotoxy(41 + i, 4);
std::cout << " ^";
color(WHITE, BLACK);
break;
case '0':
case '1':
case '2':
@ -351,7 +420,16 @@ int calculateONP(std::string s, int speed = 500)
case '7':
case '8':
case '9':
heap[counter] = tmp - '0';
numBuild += (numBuildCount * (tmp - '0'));
numBuildCount *= 10;
displayNumBuilder(numBuild);
gotoxy(42 + i, 3);
color(LIGHT_GREEN, BLACK);
std::cout << tmp;
gotoxy(41 + i, 4);
std::cout << " ^";
color(WHITE, BLACK);
/*heap[counter] = tmp - '0';
//gotoxy(3 + (2 * counter), 2);
gotoxy(2, 4 + counter);
color(YELLOW, LIGHT_PURPLE);
@ -363,7 +441,7 @@ int calculateONP(std::string s, int speed = 500)
std::cout << " ^";
color(WHITE, BLACK);
counter++;
heapPointer(counter);
heapPointer(counter);*/
break;
case '+':
calculate = heap[counter - 2] + heap[counter - 1];
@ -372,7 +450,7 @@ int calculateONP(std::string s, int speed = 500)
//(((2+2)+2)+2)+2=
//gotoxy(3 + (2 * (counter - 2)), 2);
gotoxy(2, 4 + counter - 2);
color(YELLOW, LIGHT_PURPLE);
color(YELLOW, BLACK);
std::cout << " ";
//gotoxy(3 + (2 * (counter - 1)), 2);
gotoxy(2, 4 + counter - 1);
@ -381,7 +459,7 @@ int calculateONP(std::string s, int speed = 500)
heapPointer(counter);
heap[counter++] = calculate;
heapPointer(counter);
color(YELLOW, LIGHT_PURPLE);
color(YELLOW, BLACK);
//gotoxy(3 + (2 * (counter - 1)), 2);
gotoxy(2, 4 + counter - 1);
std::cout << calculate;
@ -393,7 +471,7 @@ int calculateONP(std::string s, int speed = 500)
color(WHITE, BLACK);
break;
case '-':
calculate = heap[counter - 2] - heap[counter - 1];
/*calculate = heap[counter - 2] - heap[counter - 1];
heap[counter - 2] = 0;
heap[counter - 1] = 0;
//gotoxy(3 + (2 * (counter - 2)), 2);
@ -415,11 +493,36 @@ int calculateONP(std::string s, int speed = 500)
color(LIGHT_GREEN, BLACK);
std::cout << tmp;
gotoxy(41 + i, 4);
std::cout << " ^";
color(WHITE, BLACK);*/
calculate = heap[counter - 2] - heap[counter - 1];
heap[counter - 2] = 0;
heap[counter - 1] = 0;
//(((2+2)+2)+2)+2=
//gotoxy(3 + (2 * (counter - 2)), 2);
gotoxy(2, 4 + counter - 2);
color(YELLOW, BLACK);
std::cout << " ";
//gotoxy(3 + (2 * (counter - 1)), 2);
gotoxy(2, 4 + counter - 1);
std::cout << " ";
counter -= 2;
heapPointer(counter);
heap[counter++] = calculate;
heapPointer(counter);
color(YELLOW, BLACK);
//gotoxy(3 + (2 * (counter - 1)), 2);
gotoxy(2, 4 + counter - 1);
std::cout << calculate;
gotoxy(42 + i, 3);
color(LIGHT_GREEN, BLACK);
std::cout << tmp;
gotoxy(41 + i, 4);
std::cout << " ^";
color(WHITE, BLACK);
break;
case '*':
calculate = heap[counter - 2] * heap[counter - 1];
/*calculate = heap[counter - 2] * heap[counter - 1];
heap[counter - 2] = 0;
heap[counter - 1] = 0;
//gotoxy(3 + (2 * (counter - 2)), 2);
@ -441,6 +544,31 @@ int calculateONP(std::string s, int speed = 500)
color(LIGHT_GREEN, BLACK);
std::cout << tmp;
gotoxy(41 + i, 4);
std::cout << " ^";
color(WHITE, BLACK);*/
calculate = heap[counter - 2] * heap[counter - 1];
heap[counter - 2] = 0;
heap[counter - 1] = 0;
//(((2+2)+2)+2)+2=
//gotoxy(3 + (2 * (counter - 2)), 2);
gotoxy(2, 4 + counter - 2);
color(YELLOW, BLACK);
std::cout << " ";
//gotoxy(3 + (2 * (counter - 1)), 2);
gotoxy(2, 4 + counter - 1);
std::cout << " ";
counter -= 2;
heapPointer(counter);
heap[counter++] = calculate;
heapPointer(counter);
color(YELLOW, BLACK);
//gotoxy(3 + (2 * (counter - 1)), 2);
gotoxy(2, 4 + counter - 1);
std::cout << calculate;
gotoxy(42 + i, 3);
color(LIGHT_GREEN, BLACK);
std::cout << tmp;
gotoxy(41 + i, 4);
std::cout << " ^";
color(WHITE, BLACK);
break;
@ -467,7 +595,7 @@ int calculateONP(std::string s, int speed = 500)
color(WHITE, BLACK);
return 0;
}
calculate = heap[counter - 2] / heap[counter - 1];
/*calculate = heap[counter - 2] / heap[counter - 1];
heap[counter - 2] = 0;
heap[counter - 1] = 0;
//gotoxy(3 + (2 * (counter - 2)), 2);
@ -489,6 +617,31 @@ int calculateONP(std::string s, int speed = 500)
color(LIGHT_GREEN, BLACK);
std::cout << tmp;
gotoxy(41 + i, 4);
std::cout << " ^";
color(WHITE, BLACK);*/
calculate = heap[counter - 2] / heap[counter - 1];
heap[counter - 2] = 0;
heap[counter - 1] = 0;
//(((2+2)+2)+2)+2=
//gotoxy(3 + (2 * (counter - 2)), 2);
gotoxy(2, 4 + counter - 2);
color(YELLOW, BLACK);
std::cout << " ";
//gotoxy(3 + (2 * (counter - 1)), 2);
gotoxy(2, 4 + counter - 1);
std::cout << " ";
counter -= 2;
heapPointer(counter);
heap[counter++] = calculate;
heapPointer(counter);
color(YELLOW, BLACK);
//gotoxy(3 + (2 * (counter - 1)), 2);
gotoxy(2, 4 + counter - 1);
std::cout << calculate;
gotoxy(42 + i, 3);
color(LIGHT_GREEN, BLACK);
std::cout << tmp;
gotoxy(41 + i, 4);
std::cout << " ^";
color(WHITE, BLACK);
break;
@ -700,7 +853,7 @@ int main(int argc, char *argv[])
tmp3 >> sp3;
system("cls");
system("pause > NUL");
//system("pause > NUL");
color(GREEN, GREEN);
for(int i = 1; i <= 28; i++)