import java.io.*;
class file
{
public static void main(String args[])throws IOException
{
System.out.println("How many number you want to store:");
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
//DataInputStream in=new DataInputStream(System.in);
int n=Integer.parseInt(in.readLine());
int a[]=new int[10];
System.out.println("Enter your number");
for(int i=0;i
{ System.out.printf("The number a[%d]=",i+1);
a[i]=Integer.parseInt(in.readLine());
}
FileOutputStream fs=new FileOutputStream("test.java");
DataOutputStream ds=new DataOutputStream(fs);
for(int i=0;i
{
ds.writeInt(a[i]);
}
FileInputStream fi=new FileInputStream ("test.java");
DataInputStream di=new DataInputStream (fi);
for(int j=0;j
{
a[j]=di.readInt();
}
for(int i=0;i
{
for(int j=i+1;j
{
if(a[i]
{
int change=a[i];
a[i]=a[j];
a[j]=change;
}
}
}
System.out.println("Sorted list");
for(int i=0;i
{ System.out.printf("The number a[%d]=",i+1);
System.out.println(a[i]);
}
System.out.println();
di.close();
}
}
0 comments:
Post a Comment