Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Commit dde52ec

Browse files
authored
Add files via upload
1 parent 574eb80 commit dde52ec

File tree

1 file changed

+54
-2
lines changed

1 file changed

+54
-2
lines changed

usacotools.java

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
import java.util.*;
23
import java.io.*;
34
public 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\nYou have many choices \n1} Run help \n2} Check for a update \n3}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

Comments
 (0)