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