import java.lang.*;
import java.io.*;
import java.util.*;
class ConsoleIO
{
private static String line="";
private static BufferedReader br= new BufferedReader (new InputStreamReader(System.in));
private static StringTokenizer toks=new StringTokenizer(line);
public static int readInt() throws NumberFormatException, IOException
{
if(!toks.hasMoreTokens())
{
line=br.readLine();
toks=new StringTokenizer(line);
}
return Integer.parseInt(toks.nextToken());
}
}
class ReadASetOfIntegers extends Object
{
public static void main(String[] args) throws IOException
{
int i,sum,n,max=-1,min=-1;
System.out.print("\r\nInput the size \r\n");
n=ConsoleIO.readInt();
int[] a=new int[n];
System.out.print("\nEnter "+n+" integers, to Calculate Average.....\r\n");
for(i=0;i<n;i++)
{
a[i]=ConsoleIO.readInt();
if (i==0)
{
max=a[i];
min=a[i];
}
else
if(a[i]>max)
{
max=a[i];
}
else
if (a[i]<min)
{
min=a[i];
}
}
System.out.print("\n\nThe Maximum of all the " +n+" Numbers is : "+ max+ "\n\nThe minimum of all the " +n+" Numbers is : "+ min+"\n\n");
}
}
import java.io.*;
import java.util.*;
class ConsoleIO
{
private static String line="";
private static BufferedReader br= new BufferedReader (new InputStreamReader(System.in));
private static StringTokenizer toks=new StringTokenizer(line);
public static int readInt() throws NumberFormatException, IOException
{
if(!toks.hasMoreTokens())
{
line=br.readLine();
toks=new StringTokenizer(line);
}
return Integer.parseInt(toks.nextToken());
}
}
class ReadASetOfIntegers extends Object
{
public static void main(String[] args) throws IOException
{
int i,sum,n,max=-1,min=-1;
System.out.print("\r\nInput the size \r\n");
n=ConsoleIO.readInt();
int[] a=new int[n];
System.out.print("\nEnter "+n+" integers, to Calculate Average.....\r\n");
for(i=0;i<n;i++)
{
a[i]=ConsoleIO.readInt();
if (i==0)
{
max=a[i];
min=a[i];
}
else
if(a[i]>max)
{
max=a[i];
}
else
if (a[i]<min)
{
min=a[i];
}
}
System.out.print("\n\nThe Maximum of all the " +n+" Numbers is : "+ max+ "\n\nThe minimum of all the " +n+" Numbers is : "+ min+"\n\n");
}
}
No comments:
Post a Comment