Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #include <conio.h>
- #include <Windows.h>
- using namespace std;
- class Number{
- private:
- char string[10][10];
- int x;
- int y;
- char num;
- public:
- void Init_String();
- void Set_String(int i, char j);
- void Control_String();
- void Print_String();
- };
- void Number::Init_String(){
- for (int i = 0; i < 10; i++){
- for (int j = 0; j < 10;j++)
- string[i][j] = ' ';
- }
- }
- void Number::Set_String(int i, char j){
- int x = i / 10;
- int y = i % 10;
- num = j;
- string[x][y] = num;
- }
- void Number::Control_String(){
- char ch;
- ch = _getch();
- while (ch != 27) {
- switch (ch) {
- case 75:
- if (x == 0){
- break;
- }
- else if (x != 0){
- x -= 1;
- num -= 1;
- break;
- }
- case 77:
- if (x == 9){
- x = 9;
- string[x][y] = num;
- }
- else if (x <= 8){
- string[x][y] = 0;
- ++x;
- string[x][y] = num;
- }
- Print_String();
- break;
- case 72:
- if (y == 0){
- y = 0;
- string[x][y] = num;
- }
- else if (y > 0){
- string[x][y] = 0;
- --y;
- string[x][y] = num;
- }
- Print_String();
- break;
- case 80:
- if (y == 9){
- y = 9;
- string[x][y] = num;
- }
- else if (y < 0){
- string[x][y] = 0;
- ++y;
- string[x][y] = num;
- }
- Print_String();
- break;
- }
- ch = _getch();
- }
- }
- void Number::Print_String(){
- system("cls");
- for (int i = 0; i < 10; i++){
- for (int j = 0; j < 10; j++)
- cout << string[i][j];
- cout << endl;
- }
- }
- int main() {
- int i;
- char num;
- Number nm;
- cout << "Input Location: ";
- cin >> i;
- cout << "Input Alpha: ";
- cin >> num;
- nm.Init_String();
- nm.Set_String(i, num);
- nm.Print_String();
- nm.Control_String();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement