Help with implementation an esoteric programming language in C++! (Grid)

I have attempted at treating an implementation of To The Top Right Corner, a not implemented Esolang using a 5x5 grid. Read this article to understand how it should work.

Note that I have changed the grid in my version and it is very different.
Repl

The issue is that if you use the tokens (as shown in the article) they are not moving in the section in the right position, nor is the starting position correct. I have no previous experience with grids and have no idea how to fix this. I believe it may be due to the grid automatically starting at a different position and the X and y being different.

My version uses a different grid…

grid:
1:2:3:4:5
5: a b c d e
4: f g h i j
3: k l m n o
2: p q r s t
1: u v w x z

You can use . to print the selected letter to console.

Code

#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <string>
#ifdef _WIN32
#include <Windows.h>
#else
#include <unistd.h>
#endif

using namespace std;

// grid:
// 1:2:3:4:5
// 5: a b c d e
// 4: f g h i j
// 3: k l m n o
// 2: p q r s t
// 1: u v w x z

int main() {
  int x = 1;
  int y = 1;
  int loop = 1;
  string input, out;
  char grid[5][5] = {{'a','b','c','d','e'},
                   {'f','g','h','i','j'},
                   {'k','l','m','n','o'},
                   {'p','q','r','s','t'},
                   {'u','v','w','x','y'}};
  out=grid[x][y];
  while (loop == 1) {
    cin >> input;
    if (input == ">") {
      if(x<5){
      x = x+1;
        }
    } else if(input=="<"){
      if(x<-1){
        x = x-1;
      }
    } else if(input=="^"){
      if(y<6){
        y = y+1;
      }
    } else if(input=="v"){
      if(y>1){
        y = y-1;
      }
    } else if(input=="+"){
      if(y<6){
        y = y+1;
      }
      if(x<6){
        x = x+1;
      }
    } else if(input=="-"){
      if(y>1){
        y = y-1;
      }
      if(x<6){
        x = x+1;
      }
    } else if(input=="*"){
      if(y>1){
        y = y-1;
      }
      if(x<-1){
        x = x-1;
      }
    } else if(input=="+"){
      if(y<6){
        y = y+1;
      }
      if(x<-1){
        x = x-1;
      }
    } else if (input == ".") {
      cout<<out;
    }
    out=grid[x][y];
    // auto out = string(1,out)+grid[x][y];
  }
}

Hi @EarthRulerr can you post a link to your Repl please?

I’ve also moved this to #code-help as you are having difficulty with your code, not Replit.

Oops! I must have forgotten: https://replit.com/@EarthRulerr/ToTheTopRightCorner-Implemenation?v=1 (Nevermind, it’s there just not well labeled:

Also thanks for changing the category! I don’t know why I made it on #help

(PS.) It won’t let me edit my topic?

No problem.

It’s just because you are a new user, after a few more days you should be able to edit your posts more than once.