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
| public class Stack<T> { | |
| private T[] array; | |
| private int index; | |
| public Stack(int length) { | |
| this.index = 0; | |
| this.array = (T[]) new Object[length]; | |
| } | |
| public int size() { |
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 dz_03; | |
| import java.util.ArrayList; | |
| import java.util.Collections; | |
| public class dz_03_01 { | |
| public static void main(String[] args) { | |
| ArrayList<Integer> numList = new ArrayList<Integer>(); | |
| Collections.addAll(numList, 1, 3, 6, 3, 8, 2, 5, 8, 77, 12, 76, 22, 2, 67); |
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
| import java.io.IOException; | |
| import java.nio.file.DirectoryStream; | |
| import java.nio.file.Files; | |
| import java.nio.file.Path; | |
| import java.nio.file.Paths; | |
| public class dz_02_1 { | |
| public static void main(String[] args) throws IOException { | |
| // Path dir = Path.of("C:\\Program Files\\Java\\jdk-11.0.16\\conf\\management", |
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
| public class dz_01 { | |
| static int sum(int[] arr, int start, int end) { | |
| int sum = 0; | |
| for (int i = start; i < end; i++) { | |
| sum += arr[i]; | |
| } | |
| return sum; | |
| } |
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
| import random | |
| def print_matrix(matrix): | |
| for i in range(0, len(matrix)): | |
| for i2 in range(0, len(matrix[i])): | |
| print(matrix[i][i2], end=" ") | |
| print() | |
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
| import re | |
| def read_file(file_name): | |
| path = file_name | |
| f = open(path, "r") | |
| result = f.read().replace(" ", "") | |
| f.close() | |
| return result |
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
| def InputNumbers(inputText): | |
| is_OK = False | |
| while not is_OK: | |
| try: | |
| number = float(input(f"{inputText}")) | |
| is_OK = True | |
| except ValueError: | |
| print("Какое-то неправильное число!") | |
| return number |
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
| from random import randint | |
| def InputNumbers(inputText): | |
| is_OK = False | |
| while not is_OK: | |
| try: | |
| number = int(input(f"{inputText}")) | |
| is_OK = True | |
| except ValueError: |
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
| """ Напишите программу, которая принимает на вход вещественное число и показывает сумму его цифр. | |
| Пример: | |
| - 6782 -> 23 | |
| - 0,56 -> 11 """ | |
| def InputNumbers(inputText): | |
| is_OK = False | |
| while not is_OK: | |
| try: |
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
| """ Напишите программу, которая принимает на вход цифру, обозначающую день недели, и проверяет, является ли этот день выходным. | |
| Пример: - 6 -> да - 7 -> да - 1 -> нет """ | |
| def InputNumbers(inputText): | |
| is_OK = False | |
| while not is_OK: | |
| try: | |
| number = int(input(f"{inputText}")) | |
| is_OK = True |
NewerOlder