Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.FileReader;
- import java.io.FileWriter;
- import java.util.Scanner;
- public static void ReadFromFile (int [][] Matrixx, String FName, int Row, int Col) throws
- Exception {
- String line;
- String [] Numb;
- BufferedReader buff = new BufferedReader(new FileReader(FName));
- for (int i = 0; i <= Row; i++) {
- line = buff.readLine();
- numbers = line.split(" ");
- for (int j = 0; j <= Col; j++) {
- Matrixx[i][j] = Integer.parseInt(Numb[j]);
- }
- }
- buff.close();
- }
- public static int MatrixRowSize(String FName) throws Exception {
- int count = 0;
- FileReader MyFile = new FileReader(FName);
- BufferedReader buff = new BufferedReader(MyFile);
- while (buff.readLine() != null) {
- count++;
- }
- FileIn.close();
- return (count);
- }
- public static int MatrixColSize(String FName) throws Exception {
- String line;
- String[] Numb;
- int count = 0;
- FileReader MyFile = new FileReader(FName);
- BufferedReader buff = new BufferedReader(MyFile);
- line = buff.readLine();
- numbers = line.split(" ");
- for (int i = 0; i < numbers.length; i++)
- count++;
- FileIn.close();
- return (count);
- }
- public static void WriteToFile (float Arr[], String FName, int Row, int Col)
- throws Exception {
- FileWriter FileOut = new FileWriter(FileName);
- for (int i = 0; i <= Row; i++) {
- FileOut.write(Arr[i] + " ");
- }
- FileOut.write("\n");
- }
- FileOut.close();
- System.out.println("Saved to file: " + FName);
- }
- }
- public static void Average(int [][] Matrixx, int Col, int Row)
- {
- int i, j;
- float avg;
- for (j = 0; j < Col; j++) {
- for (i = 0; i < Row; i++)
- avg += Matrixx[j][i];
- printf("%.4f ", avg / row);
- }
- return 0;
- }
- public static void float AverageOutput(int [] Arr; int Row){
- int i;
- float avg;
- for (int i = 0, i < Row, i++){
- printf("%.4f ", avg / row);
- }
- }
- public static void MatrixOutput (int [][] Matrixx, int Row, int Col) {
- for (int i = 0; i <= Row; i++) {
- for (int j = 0; j <= Col; j++) {
- System.out.printf("%d ", Matrixx[i][j]);
- }
- System.out.println();
- }
- System.out.println();
- }
Advertisement
Add Comment
Please, Sign In to add comment