1+
12import java .util .*;
23import java .io .*;
34public abstract class usacotools {
@@ -184,8 +185,60 @@ public static void run(String exe){
184185 }
185186 public static boolean ESTACK =true ;
186187 public static boolean EMSG =true ;
187-
188+ public static int [] reverse (int [] a ) {
189+ int temp ;
190+ for (int i = 0 ; i < a .length / 2 ; i ++)
191+ {
192+ temp = a [i ];
193+ a [i ] = a [a .length - i - 1 ];
194+ a [a .length - i - 1 ] = temp ;
195+ }
196+ return a ;
197+ }
198+ public static int [][] reverseh (int [][] a ) {
199+ /*
200+ * Reverse 2D array horizontal
201+ */
202+ int [] temp ;
203+ for (int i = 0 ; i < a .length / 2 ; i ++)
204+ {
205+ temp = a [i ];
206+ a [i ] = a [a .length - i - 1 ];
207+ a [a .length - i - 1 ] = temp ;
208+ }
209+ return a ;
210+ }
211+ public static int [][] reversev (int [][] a ) {
212+ /*
213+ * Reverse 2D array vertically
214+ */
215+ int [][] newa =new int [a .length ][a [0 ].length ];
216+ for (int i =0 ;i <a .length ;i ++) {
217+ newa [i ]=reverse (a [i ]);
218+ }
219+ return newa ;
220+ }
221+ public static int [][] rotate90cw (int [][] map ) {
222+ /*
223+ * Rotate 2D array
224+ * 90 degree clockwise
225+ */
226+ int N =map .length ;
227+ int [][] n =new int [N ][N ];
228+ for (int i =0 ;i <N ;i ++) {
229+ for (int j =0 ;j <N ;j ++) {
230+ n [j ][N -1 -i ]=map [i ][j ];
231+ }
232+ }
233+ return n ;
234+ }
188235 public static void main (String [] args ) throws Exception {
236+ /*
237+ * Short demo of stuff
238+ * Making an error would also demo error reporting
239+ *
240+ *
241+ */
189242 System .out .println ("Running demo" );
190243 Scanner sc =getsysscan ();
191244 print ("Welcome to the demo\n You have many choices \n 1} Run help \n 2} Check for a update \n 3}Run demo to see features" );
@@ -204,5 +257,4 @@ public static void main(String[] args) throws Exception{
204257
205258 }
206259 }
207-
208260}
0 commit comments