1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
import java.io.*;
public class Lire
{
public static String S() // Lire un String
{
String tmp = "";
char C='\0';
try {
while ((C=(char) System.in.read()) !='\n')
{
if (C != '\r') tmp = tmp+C;
}
}
catch (IOException e)
{
System.out.println("Erreur de frappe");
System.exit(0);
}
return tmp;
} // fin de S()
public static byte b() // Lire un entier byte
{
byte x=0;
try {
x=Byte.parseByte(S());
}
catch (NumberFormatException e) {
System.out.println("Format numérique incorrect");
System.exit(0);
}
return x ;
}
public static short s() // Lire un entier short
{
short x=0;
try {
x=Short.parseShort(S());
}
catch (NumberFormatException e) {
System.out.println("Format numérique incorrect");
System.exit(0);
}
return x ;
}
public static int i() // Lire un entier
{
int x=0;
try {
x=Integer.parseInt(S());
}
catch (NumberFormatException e) {
System.out.println("Format numérique incorrect");
System.exit(0);
}
return x ;
}
public static long l() // Lire un entier long
{
long x=0;
try {
x=Integer.parseInt(S());
}
catch (NumberFormatException e) {
System.out.println("Format numérique incorrect");
System.exit(0);
}
return x ;
}
public static double d() // Lire un double
{
double x=0.0;
try {
x=Double.valueOf(S()).doubleValue();
}
catch (NumberFormatException e) {
System.out.println("Format numérique incorrect");
System.exit(0);
}
return x ;
}
public static float f() // Lire un float
{
float x=0.0f;
try {
x=Double.valueOf(S()).floatValue();
}
catch (NumberFormatException e)
{
System.out.println("Format numérique incorrect");
System.exit(0);
}
return x ;
}
public static char c() // Lire un caractere
{
String tmp=S();
if (tmp.length()==0)
return '\n';
else
{
return tmp.charAt(0);
}
}
} |
Partager