Hex Artifact Content
Not logged in

Artifact d8235f29f64235d208760f4a59480ca7a85cb9d1:


0000: 23 69 6e 63 6c 75 64 65 20 3c 73 74 72 69 6e 67  #include <string
0010: 3e 0a 23 69 6e 63 6c 75 64 65 20 3c 73 74 61 63  >.#include <stac
0020: 6b 3e 0a 75 73 69 6e 67 20 6e 61 6d 65 73 70 61  k>.using namespa
0030: 63 65 20 73 74 64 3b 0a 0a 73 74 72 75 63 74 20  ce std;..struct 
0040: 4d 61 67 69 63 53 70 65 6c 6c 0a 7b 0a 09 73 74  MagicSpell.{..st
0050: 72 69 6e 67 20 66 69 78 54 68 65 53 70 65 6c 6c  ring fixTheSpell
0060: 28 20 73 74 72 69 6e 67 20 73 70 65 6c 6c 20 29  ( string spell )
0070: 0a 09 7b 0a 09 09 73 74 61 63 6b 3c 63 68 61 72  ..{...stack<char
0080: 3e 20 73 3b 0a 09 09 66 6f 72 28 69 6e 74 20 69  > s;...for(int i
0090: 3d 30 3b 20 69 3c 73 70 65 6c 6c 2e 73 69 7a 65  =0; i<spell.size
00a0: 28 29 3b 20 2b 2b 69 29 0a 09 09 09 69 66 28 20  (); ++i)....if( 
00b0: 73 70 65 6c 6c 5b 69 5d 3d 3d 27 41 27 20 7c 7c  spell[i]=='A' ||
00c0: 20 73 70 65 6c 6c 5b 69 5d 3d 3d 27 5a 27 20 29   spell[i]=='Z' )
00d0: 0a 09 09 09 09 73 2e 70 75 73 68 28 20 73 70 65  .....s.push( spe
00e0: 6c 6c 5b 69 5d 20 29 3b 0a 09 09 66 6f 72 28 69  ll[i] );...for(i
00f0: 6e 74 20 69 3d 30 3b 20 69 3c 73 70 65 6c 6c 2e  nt i=0; i<spell.
0100: 73 69 7a 65 28 29 3b 20 2b 2b 69 29 0a 09 09 09  size(); ++i)....
0110: 69 66 28 20 73 70 65 6c 6c 5b 69 5d 3d 3d 27 41  if( spell[i]=='A
0120: 27 20 7c 7c 20 73 70 65 6c 6c 5b 69 5d 3d 3d 27  ' || spell[i]=='
0130: 5a 27 20 29 0a 09 09 09 09 73 70 65 6c 6c 5b 69  Z' ).....spell[i
0140: 5d 3d 73 2e 74 6f 70 28 29 2c 20 73 2e 70 6f 70  ]=s.top(), s.pop
0150: 28 29 3b 0a 09 09 72 65 74 75 72 6e 20 73 70 65  ();...return spe
0160: 6c 6c 3b 0a 09 7d 0a 7d 3b 0a                    ll;..}.};.