java algoritmi

Download java algoritmi

If you can't read please download the document

Upload: miha-ela

Post on 13-Nov-2015

3 views

Category:

Documents


0 download

DESCRIPTION

sortari, dijkstra

TRANSCRIPT

//6-33package testjv;import java.io.DataInputStream;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.IOException;import java.util.Arrays;public class Testjv { public static void main(String[] args) throws IOException { FileInputStream fis = null; try{ fis=new FileInputStream("input.txt"); } catch(FileNotFoundException fe) { fe.printStackTrace(); } String str = null; DataInputStream dis = new DataInputStream(fis); int n; // citirea numarului de elemente while(true){ str = dis.readLine(); try{ n = Integer.parseInt(str); System.out.println(n); break; } catch(NumberFormatException nf){ System.out.println("Conversie imposibila :("); } } String elem[] = new String[n]; int i=0; //citirea numelui studentilor try{ while(((str = dis.readLine()) != null)&&i