OC push box, push box

Source: Internet
Author: User

OC push box, push box

# Include <stdio. h> # include <stdlib. h> int main (void) {char sr; // store user input commands // draw map char a [11] [20] = {"################## #", "##################", "####$ ###", "###########","######", "###############","####@####", ###", "###################", "##################"}; // defines the coordinates of a box, a small person, and a target, int I = 1, e = 8, f = 9, m = 7, n = 9, x = 6, y = 9; while (I) {// clear the screen, it gives a sense of real gaming. This is in the MAC environment, and the clear screen Statement of WIN is sys. Tem ("cls") // The type and syntax used by this program. Besides the clear screen clause and the clear cache, both can be used in the WIN system, the perfect running system ("clear") in VC ++ 6.0; printf ("welcome to use the push Box \ n ^ to represent you, and your job is to push @ to the position of $, work hard! \ N "); printf (" w stands for upper, s stands for lower, a stands for left, d stands for right, q stands for exit, start! \ N "); // determine whether to push to the destination if (m = 2 & n = 8) {if (x = 2 & y = 10) {printf ("Congratulations! You have succeeded! \ N "); break ;}}if (m = 2 & n = 10) {if (x = 2 & y = 8) {printf ("Congratulations! You have succeeded! \ N "); break ;}// print the map for (int B = 0; B <11; B ++) {for (int c = 0; c <20; c ++) {printf ("% c", a [B] [c]);} printf ("\ n ");} // clear the cache fpurge (stdin); scanf ("% c", & sr); // switch (sr) {case 'W ': if (a [E-1] [f] = '') {a [E-1] [f] = '^'; a [e] [f] = ''; e-= 1;} else if (a [E-1] [f] = '@' & a [E-2] [f]! = '#' & A [E-2] [f]! = '@') {If (e-m = 1 & f = n) {m-= 1; a [m] [n] = '@'; a [E-1] [f] = '^'; a [e] [f] = ''; e-= 1 ;} else if (e-x = 1 & f = y) {x-= 1; a [x] [y] = '@'; a [E-1] [f] = '^'; a [e] [f] = ''; e-= 1 ;}} break; case's ': case's ': if (a [e + 1] [f] = '') {a [e + 1] [f] =' ^ '; a [e] [f] = ''; e + = 1 ;} else if (a [e + 1] [f] = '@' & a [e + 2] [f]! = '#' & A [e + 2] [f]! = '@') {If (m-e = 1 & f = n) {m + = 1; a [m] [n] = '@'; a [e + 1] [f] = '^'; a [e] [f] = ''; e + = 1 ;} else if (x-e = 1 & y = f) {x + = 1; a [x] [y] = '@'; a [e + 1] [f] = '^'; a [e] [f] = ''; e + = 1 ;}} break; case 'A ': case 'A': if (A [e] [F-1] = '') {a [e] [F-1] = '^ '; if (e = 2 & f = 8) | (e = 2 & f = 10 )) a [e] [f] = '$'; else a [e] [f] = ''; f-= 1 ;} else if (a [e] [F-1] = '$') {a [e] [F-1] = '^ '; if (e = 2 & f = 8) | (e = 2 & f = 10 )) a [e] [f] = '$'; else [E] [f] = ''; f-= 1 ;} else if (a [e] [F-1] = '@' & a [e] [F-2]! = '#' & A [e] [F-2]! = '@') {If (e = m & f-n = 1) {n-= 1; a [m] [n] = '@'; a [e] [F-1] = '^'; if (e = 2 & f = 8) | (e = 2 & f = 10) a [e] [f] = '$'; else a [e] [f] = ''; f-= 1;} else if (e = x & f-y = 1) {y-= 1; a [x] [y] = '@'; a [e] [F-1] = '^'; if (e = 2 & f = 8) | (e = 2 & f = 10) a [e] [f] = '$'; else a [e] [f] = ''; f-= 1 ;}} break; case 'D': if (a [e] [f + 1] = '') {a [e] [f + 1] = '^'; if (e = 2 & f = 8) | (e = 2 & f = 10) a [e] [f] = '$'; else a [e] [f] =' '; F + = 1;} else if (a [e] [f + 1] =' $ ') {a [e] [f + 1] = '^'; if (e = 2 & f = 8) | (e = 2 & f = 10) a [e] [f] = '$'; else a [e] [f] = ''; f + = 1;} else if (a [e] [f + 1] = '@' & a [e] [f + 2]! = '#' & A [e] [f + 2]! = '@') {If (e = m & n-f = 1) {n + = 1; a [m] [n] = '@'; a [e] [f + 1] = '^'; if (e = 2 & f = 8) | (e = 2 & f = 10) a [e] [f] = '$'; else a [e] [f] = ''; f + = 1;} else if (e = x & y-f = 1) {y + = 1; a [x] [y] = '@'; a [e] [f + 1] = '^'; if (e = 2 & f = 8) | (e = 2 & f = 10) a [e] [f] = '$'; else a [e] [f] = ''; f + = 1 ;}} break; case 'q': I = 0; break ;}} return 0 ;}

  

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.