Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. package Algorithms;
  2. import java.io.File;
  3. import java.util.Scanner;
  4. import java.util.*;
  5.  
  6. public class Driver {
  7.  
  8. public static void main(String[] args) throws java.io.FileNotFoundException {
  9.  
  10. Scanner scan = new Scanner(new File("src/Algorithms/input.txt"));
  11. int rows = 0;
  12. int columns = 0;
  13. scan.nextLine();
  14. while(scan.hasNextLine()) {
  15. rows++;
  16. Scanner colReader = new Scanner(scan.nextLine());
  17. columns = 0;
  18. while(colReader.hasNextDouble()) {
  19. columns++;
  20. }
  21. }
  22.  
  23. rows = rows - 1;
  24. double arr[][] = new double[rows][columns];
  25. scan.close();
  26.  
  27. scan = new Scanner(new File("array.txt"));
  28. int n = scan.nextInt();
  29. scan.nextLine();
  30. for(int i = 0; i < rows; i++) {
  31. for(int j = 0; j < columns; j++) {
  32. if(scan.hasNextDouble()) {
  33. arr[i][j] = scan.nextDouble();
  34. }
  35. }
  36. }
  37. double vector[] = new double[n];
  38. for(int i = 0;i < n; i++) {
  39. if(scan.hasNextDouble()){
  40. vector[i] = scan.nextDouble();
  41. }
  42. }
  43. scan.close();
  44.  
  45. NaiveGaussianAlgorithm NGE = new NaiveGaussianAlgorithm();
  46. NGE.naiveGaussian(arr, vector);
  47. System.out.println(columns);
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement