Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // VitosFamily.java
- // Jeffrey Cartagena
- import java.io.*;
- import java.util.Scanner;
- public class VitosFamily {
- public static void main(String[] args) throws IOException{
- try{
- Scanner inFile = new Scanner(new FileReader("data.in"));
- PrintWriter outFile = new PrintWriter(new FileWriter("data.out"));
- int qty = inFile.nextInt();
- int sentinel = 0;
- while(sentinel < qty)
- {
- int relatives = inFile.nextInt();
- int[] streets = new int[relatives];
- for(int i=0; i < relatives; i++)
- streets[i] = inFile.nextInt();
- int result = 0;
- for(int i=relatives-1; i>0; i--)
- result += (streets[i] - streets[i-1]);
- outFile.println(result);
- sentinel++;
- }
- System.out.println("Finishing the program");
- System.in.read();
- inFile.close();
- outFile.close();
- }
- catch(IOException ex)
- {
- System.out.println("There is no input file");
- System.in.read();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement