Skip to content

Commit de6c1fe

Browse files
committed
iniciando trabalho pratico de sobre métodos de ordenação
1 parent b74da8a commit de6c1fe

File tree

11 files changed

+5529
-0
lines changed

11 files changed

+5529
-0
lines changed
1.77 KB
Binary file not shown.
1.86 KB
Binary file not shown.
3.5 KB
Binary file not shown.

nba/ordenacao/src/App.class

1.88 KB
Binary file not shown.

nba/ordenacao/src/App.java

Lines changed: 409 additions & 0 deletions
Large diffs are not rendered by default.

nba/ordenacao/src/MyIO.class

5.48 KB
Binary file not shown.

nba/ordenacao/src/MyIO.java

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
import java.io.*;
2+
import java.nio.charset.*;
3+
4+
class MyIO {
5+
6+
private static BufferedReader in = new BufferedReader(new InputStreamReader(System.in, Charset.forName("ISO-8859-1")));
7+
private static String charset = "ISO-8859-1";
8+
9+
public static void setCharset(String charset_){
10+
charset = charset_;
11+
in = new BufferedReader(new InputStreamReader(System.in, Charset.forName(charset)));
12+
}
13+
14+
public static void print(){
15+
}
16+
17+
public static void print(int x){
18+
try {
19+
PrintStream out = new PrintStream(System.out, true, charset);
20+
out.print(x);
21+
}catch(UnsupportedEncodingException e){ System.out.println("Erro: charset invalido"); }
22+
}
23+
24+
public static void print(double x){
25+
try {
26+
PrintStream out = new PrintStream(System.out, true, charset);
27+
out.print(x);
28+
}catch(UnsupportedEncodingException e){ System.out.println("Erro: charset invalido"); }
29+
}
30+
31+
public static void print(String x){
32+
try {
33+
PrintStream out = new PrintStream(System.out, true, charset);
34+
out.print(x);
35+
}catch(UnsupportedEncodingException e){ System.out.println("Erro: charset invalido"); }
36+
}
37+
38+
public static void print(boolean x){
39+
try {
40+
PrintStream out = new PrintStream(System.out, true, charset);
41+
out.print(x);
42+
}catch(UnsupportedEncodingException e){ System.out.println("Erro: charset invalido"); }
43+
}
44+
45+
public static void print(char x){
46+
try {
47+
PrintStream out = new PrintStream(System.out, true, charset);
48+
out.print(x);
49+
}catch(UnsupportedEncodingException e){ System.out.println("Erro: charset invalido"); }
50+
}
51+
52+
public static void println(){
53+
}
54+
55+
public static void println(int x){
56+
try {
57+
PrintStream out = new PrintStream(System.out, true, charset);
58+
out.println(x);
59+
}catch(UnsupportedEncodingException e){ System.out.println("Erro: charset invalido"); }
60+
}
61+
62+
public static void println(double x){
63+
try {
64+
PrintStream out = new PrintStream(System.out, true, charset);
65+
out.println(x);
66+
}catch(UnsupportedEncodingException e){ System.out.println("Erro: charset invalido"); }
67+
}
68+
69+
public static void println(String x){
70+
try {
71+
PrintStream out = new PrintStream(System.out, true, charset);
72+
out.println(x);
73+
}catch(UnsupportedEncodingException e){ System.out.println("Erro: charset invalido"); }
74+
}
75+
76+
public static void println(boolean x){
77+
try {
78+
PrintStream out = new PrintStream(System.out, true, charset);
79+
out.println(x);
80+
}catch(UnsupportedEncodingException e){ System.out.println("Erro: charset invalido"); }
81+
}
82+
83+
public static void println(char x){
84+
try {
85+
PrintStream out = new PrintStream(System.out, true, charset);
86+
out.println(x);
87+
}catch(UnsupportedEncodingException e){ System.out.println("Erro: charset invalido"); }
88+
}
89+
90+
public static void printf(String formato, double x){
91+
try {
92+
PrintStream out = new PrintStream(System.out, true, charset);
93+
out.printf(formato, x);// "%.2f"
94+
}catch(UnsupportedEncodingException e){ System.out.println("Erro: charset invalido"); }
95+
}
96+
97+
public static double readDouble(){
98+
double d = -1;
99+
try{
100+
d = Double.parseDouble(readString().trim().replace(",","."));
101+
}catch(Exception e){}
102+
return d;
103+
}
104+
105+
public static double readDouble(String str){
106+
try {
107+
PrintStream out = new PrintStream(System.out, true, charset);
108+
out.print(str);
109+
}catch(UnsupportedEncodingException e){ System.out.println("Erro: charset invalido"); }
110+
return readDouble();
111+
}
112+
113+
public static float readFloat(){
114+
return (float) readDouble();
115+
}
116+
117+
public static float readFloat(String str){
118+
return (float) readDouble(str);
119+
}
120+
121+
public static int readInt(){
122+
int i = -1;
123+
try{
124+
i = Integer.parseInt(readString().trim());
125+
}catch(Exception e){}
126+
return i;
127+
}
128+
129+
public static int readInt(String str){
130+
try {
131+
PrintStream out = new PrintStream(System.out, true, charset);
132+
out.print(str);
133+
}catch(UnsupportedEncodingException e){ System.out.println("Erro: charset invalido"); }
134+
return readInt();
135+
}
136+
137+
public static String readString(){
138+
String s = "";
139+
char tmp;
140+
try{
141+
do{
142+
tmp = (char)in.read();
143+
if(tmp != '\n' && tmp != ' ' && tmp != 13){
144+
s += tmp;
145+
}
146+
}while(tmp != '\n' && tmp != ' ');
147+
}catch(IOException ioe){
148+
System.out.println("lerPalavra: " + ioe.getMessage());
149+
}
150+
return s;
151+
}
152+
153+
public static String readString(String str){
154+
try {
155+
PrintStream out = new PrintStream(System.out, true, charset);
156+
out.print(str);
157+
}catch(UnsupportedEncodingException e){ System.out.println("Erro: charset invalido"); }
158+
return readString();
159+
}
160+
161+
public static String readLine(){
162+
String s = "";
163+
char tmp;
164+
try{
165+
do{
166+
tmp = (char)in.read();
167+
if(tmp != '\n' && tmp != 13){
168+
s += tmp;
169+
}
170+
}while(tmp != '\n');
171+
}catch(IOException ioe){
172+
System.out.println("lerPalavra: " + ioe.getMessage());
173+
}
174+
return s;
175+
}
176+
177+
public static String readLine(String str){
178+
try {
179+
PrintStream out = new PrintStream(System.out, true, charset);
180+
out.print(str);
181+
}catch(UnsupportedEncodingException e){ System.out.println("Erro: charset invalido"); }
182+
return readLine();
183+
}
184+
185+
public static char readChar(){
186+
char resp = ' ';
187+
try{
188+
resp = (char)in.read();
189+
}catch(Exception e){}
190+
return resp;
191+
}
192+
193+
public static char readChar(String str){
194+
try {
195+
PrintStream out = new PrintStream(System.out, true, charset);
196+
out.print(str);
197+
}catch(UnsupportedEncodingException e){ System.out.println("Erro: charset invalido"); }
198+
return readChar();
199+
}
200+
201+
public static boolean readBoolean(){
202+
boolean resp = false;
203+
String str = "";
204+
205+
try{
206+
str = readString();
207+
}catch(Exception e){}
208+
209+
if(str.equals("true") || str.equals("TRUE") || str.equals("t") || str.equals("1") ||
210+
str.equals("verdadeiro") || str.equals("VERDADEIRO") || str.equals("V")){
211+
resp = true;
212+
}
213+
214+
return resp;
215+
}
216+
217+
public static boolean readBoolean(String str){
218+
try {
219+
PrintStream out = new PrintStream(System.out, true, charset);
220+
out.print(str);
221+
}catch(UnsupportedEncodingException e){ System.out.println("Erro: charset invalido"); }
222+
return readBoolean();
223+
}
224+
225+
public static void pause(){
226+
try{
227+
in.read();
228+
}catch(Exception e){}
229+
}
230+
231+
public static void pause(String str){
232+
try {
233+
PrintStream out = new PrintStream(System.out, true, charset);
234+
out.print(str);
235+
}catch(UnsupportedEncodingException e){ System.out.println("Erro: charset invalido"); }
236+
pause();
237+
}
238+
}
239+

0 commit comments

Comments
 (0)