Created
May 23, 2020 07:39
-
-
Save olegrewko/acdabe9102baec5c2decb5860d3be91d to your computer and use it in GitHub Desktop.
Таблица умножения тройной цикл + функция
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package IgorDolgov; | |
| import java.io.File; | |
| import java.io.FileWriter; | |
| import java.io.IOException; | |
| import java.io.PrintWriter; | |
| import java.util.Arrays; | |
| import java.util.Scanner; | |
| public class TableA { | |
| static int m; | |
| // Таблица умножения с тройным циклом и выносом метода умножения в отдельный метод | |
| // И с записью длины строки в файл, цель была чтобы пунктирная линия печаталась ровно по длинне таблицы | |
| // Цель не достигнута на все 100% | |
| // И самые нижние строчки тоже едут | |
| // Поэтому все плохо | |
| private static int umno(int i, int j) { | |
| return i * j; | |
| } | |
| public static void main(String[] args) throws IOException { | |
| for (int k = 0; k < 3; k++) { | |
| for (int i = 1; i < 10; i++) { | |
| String s = " "; | |
| for (int j = 1 + m; j < 6 + m; j++) { | |
| s += (Integer.toString(i) + " * " + Integer.toString(j) + " = " + Integer.toString(umno(i, j)) + "\t\t\t\t"); | |
| } | |
| System.out.println(s); | |
| File file = new File("index01.txt"); | |
| PrintWriter sw = new PrintWriter(file); | |
| sw.println(s.length()); | |
| FileWriter pw = new FileWriter("index01.txt"); | |
| pw.write(s.length()); | |
| sw.close(); | |
| } | |
| m = m + 5; | |
| File file = new File("index01.txt"); | |
| Scanner scanner = new Scanner(file); | |
| int x = scanner.nextInt(); | |
| char[] filledArray = new char[x + 10]; | |
| Arrays.fill(filledArray, '-'); | |
| System.out.println(filledArray); | |
| scanner.close(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment