Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <conio.h>
- using namespace std;
- int main()
- {
- char ch,a[51][51];
- int n=10,x=1,y=1;
- system("color 02");
- cout<<"w-sus s-jos a-stanga d-dreapta Esc stop"<<endl;
- for(int i=1;i<=n;i++){ ///linia i
- for(int j=1;j<=n;j++){ ///coloana j
- a[i][j]=' ';
- }
- }
- a[2][3]='$'; ///pun la linia 2 si col 3 caracterul $
- while(int(ch)!=27){ ///pana la Esc
- a[x][y]='*';
- for(int i=1;i<=n;i++){ ///afisez continutul lui a [tabelul]
- for(int j=1;j<=n;j++){
- cout<<a[i][j];
- }
- cout<<endl;
- }
- ch=_getch();
- a[x][y]=' ';
- if(ch=='w') x--;
- if(ch=='s') x++;
- if(ch=='a') y--;
- if(ch=='d') y++;
- system("cls");
- if(x==2 && y==3) {
- cout<<"Felicitari!!!!";
- break; ///sar din while
- }
- cout<<int(ch)<<" "<<ch<<endl;
- }
- cout<<"Endgame";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement