mirror of
https://github.com/ASDjonok/OOP_IO-2x_2023.git
synced 2026-04-02 05:31:49 +03:00
Compare commits
20 Commits
master_old
...
9813f75326
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9813f75326 | ||
|
|
8ae3907d24 | ||
|
|
a011fc41cf | ||
|
|
4454d46284 | ||
|
|
4d70c6a51e | ||
|
|
8db686fac0 | ||
|
|
a48fb7d41f | ||
|
|
09f2114de6 | ||
|
|
828dedc3b6 | ||
|
|
41b6eb063c | ||
|
|
bb2c8bd1a0 | ||
|
|
88a618647d | ||
|
|
f4fccadb7b | ||
|
|
fb4c2404f7 | ||
|
|
86940aa666 | ||
|
|
1e368a1324 | ||
|
|
559b03336e | ||
|
|
0a7521af40 | ||
|
|
0b51a1a491 | ||
|
|
f54eee595c |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,2 +0,0 @@
|
|||||||
# Project exclude paths
|
|
||||||
/out/
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module type="JAVA_MODULE" version="4">
|
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
||||||
<exclude-output />
|
|
||||||
<content url="file://$MODULE_DIR$">
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
||||||
61
lab1_with_extracted_method/Program.cs
Normal file
61
lab1_with_extracted_method/Program.cs
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
public class Lab1
|
||||||
|
{
|
||||||
|
public static void Main(String[] args)
|
||||||
|
{
|
||||||
|
/*o1 = +
|
||||||
|
c3 = 0
|
||||||
|
o2 = *
|
||||||
|
c7 = short */
|
||||||
|
|
||||||
|
// var A = 4;
|
||||||
|
// short B = 3;
|
||||||
|
// var N = 10;
|
||||||
|
// var M = 10;
|
||||||
|
//
|
||||||
|
// var C = 1;
|
||||||
|
// var s = 0;
|
||||||
|
//
|
||||||
|
// bool divisionByZero=false;
|
||||||
|
|
||||||
|
|
||||||
|
Calculation(4, 3, 10, 10, 1, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Calculation(int A, int C, int N, short B, int M, bool divisionByZero)
|
||||||
|
{
|
||||||
|
var s = 0;
|
||||||
|
if ((A <= -C && -C <= N) || (B <= 0 && 0 <= M))
|
||||||
|
{
|
||||||
|
Console.WriteLine("Division by zero!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = A; i <= N; i++)
|
||||||
|
{
|
||||||
|
if (i + C == 0)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Division by zero!");
|
||||||
|
divisionByZero = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (short j = B; j <= M; j++)
|
||||||
|
{
|
||||||
|
if (j == 0)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Оскільки j = 0, то сума просто буде 0");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
s += (i * j) / (i + C);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!divisionByZero)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"s = {s};");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
52
laboratorna1/Program.cs
Normal file
52
laboratorna1/Program.cs
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
public class Lab1
|
||||||
|
{
|
||||||
|
public static void Main(String[] args)
|
||||||
|
{
|
||||||
|
/*o1 = +
|
||||||
|
c3 = 0
|
||||||
|
o2 = *
|
||||||
|
c7 = short */
|
||||||
|
|
||||||
|
var A = 4;
|
||||||
|
short B = 3;
|
||||||
|
var N = 10;
|
||||||
|
var M = 10;
|
||||||
|
|
||||||
|
var C = 1;
|
||||||
|
var s = 0;
|
||||||
|
|
||||||
|
bool divisionByZero=false;
|
||||||
|
|
||||||
|
|
||||||
|
if ((A <= -C && -C <= N) || (B <= 0 && 0 <= M))
|
||||||
|
{
|
||||||
|
Console.WriteLine("Division by zero!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = A; i <= N; i++)
|
||||||
|
{
|
||||||
|
if (i + C == 0) {
|
||||||
|
Console.WriteLine("Division by zero!");
|
||||||
|
divisionByZero = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for (short j = B; j <= M; j++)
|
||||||
|
{
|
||||||
|
if (j == 0) {
|
||||||
|
Console.WriteLine("Оскільки j = 0, то сума просто буде 0");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
s += (i * j) / (i + C);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!divisionByZero)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"s = {s};" );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,36 +1,13 @@
|
|||||||
public class Lab2 {
|
public class Lab2 {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
final int A = 2;
|
int[] array = {1, 2, 3};
|
||||||
final int[][] MATRIX_B = {
|
/*for (int i = 0; i < array.length; i++) {
|
||||||
{1, 202, 1, 1, 202, 3, 1, 202, 3,},
|
|
||||||
{1, 202, 1, 1, 202, 3, 1, 202, 3,},
|
|
||||||
{1, 1, 3, 1, 202, 3, 1, 202, 3,},
|
|
||||||
// {4, 5, 6,},
|
|
||||||
};
|
|
||||||
|
|
||||||
int[][] MATRIX_C = multiplication(A, MATRIX_B);
|
|
||||||
|
|
||||||
print(MATRIX_C);
|
|
||||||
|
|
||||||
System.out.println("Sum of smallest elements in every column: " + sumOfSmallestElementsInEveryColumn(MATRIX_C));
|
|
||||||
|
|
||||||
/*int[] array = {1, 2, 3};
|
|
||||||
int[] array2 = new int[3];
|
|
||||||
Object[] array3 = new String[3];
|
|
||||||
System.out.println(array3[0]); //nothing, trash from the memory, null || null
|
|
||||||
System.out.println(array2[0]); //nothing, trash from the memory, null || 0
|
|
||||||
System.out.println(array[0]); // || 1
|
|
||||||
|
|
||||||
int[][] matrix2 = new int[2][3];
|
|
||||||
matrix2[0] = new int[2];
|
|
||||||
matrix2[1] = new int[1];
|
|
||||||
for (int i = 0; i < array.length; i++) {
|
|
||||||
if (i % 2 == 0) {
|
if (i % 2 == 0) {
|
||||||
System.out.println("!" + array[i]);
|
System.out.println("!" + array[i]);
|
||||||
} else {
|
} else {
|
||||||
System.out.println("?" + array[i]);
|
System.out.println("?" + array[i]);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
for (int i = 0; i < array.length; i+=2) {
|
for (int i = 0; i < array.length; i+=2) {
|
||||||
System.out.println("!" + array[i]);
|
System.out.println("!" + array[i]);
|
||||||
@@ -45,58 +22,5 @@ public class Lab2 {
|
|||||||
{1, 2},
|
{1, 2},
|
||||||
{3}
|
{3}
|
||||||
};
|
};
|
||||||
|
|
||||||
// C=a×B, a - const
|
|
||||||
|
|
||||||
|
|
||||||
// final int[][] MATRIX_C = int;
|
|
||||||
|
|
||||||
|
|
||||||
MATRIX_B[0][0] = 2;
|
|
||||||
MATRIX_B[0] = new int[]{1, 2};
|
|
||||||
System.out.println(MATRIX_B[0][0]);
|
|
||||||
MATRIX_B = new int[][]{
|
|
||||||
{1, 2},
|
|
||||||
{3}
|
|
||||||
};*/
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int sumOfSmallestElementsInEveryColumn(final int[][] MATRIX_C) {
|
|
||||||
// todo check different length of rows
|
|
||||||
// todo try to change i and j
|
|
||||||
// todo check repetition of minimal elements
|
|
||||||
int sum = 0;
|
|
||||||
for (int i = 0; i < MATRIX_C[0].length; i++) {
|
|
||||||
int tmpSmallest = MATRIX_C[0][i];
|
|
||||||
for (int j = 1; j < MATRIX_C.length; j++) {
|
|
||||||
if (MATRIX_C[j][i] < tmpSmallest) {
|
|
||||||
tmpSmallest = MATRIX_C[j][i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sum += tmpSmallest;
|
|
||||||
}
|
|
||||||
return sum;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void print(final int[][] MATRIX_C) {
|
|
||||||
for (int i = 0; i < MATRIX_C.length; i++) {
|
|
||||||
for (int j = 0; j < MATRIX_C[i].length; j++) {
|
|
||||||
// System.out.print(MATRIX_C[i][j] + "\t");//printf("%4d",
|
|
||||||
System.out.printf("%4d ", MATRIX_C[i][j]);//printf("%4d",
|
|
||||||
}
|
|
||||||
System.out.println();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int[][] multiplication(int A, final int[][] MATRIX_B) {
|
|
||||||
final int[][] MATRIX_C = new int[MATRIX_B.length][/*MATRIX_B[0].length*/]; // todo !!!DANGER different lengths of rows
|
|
||||||
// final int[][] MATRIX_C = MATRIX_B;
|
|
||||||
for (int i = 0; i < MATRIX_B.length; i++) {
|
|
||||||
MATRIX_C[i] = new int[MATRIX_B[i].length];
|
|
||||||
for (int j = 0; j < MATRIX_B[i].length; j++) {
|
|
||||||
MATRIX_C[i][j] = MATRIX_B[i][j] * A;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return MATRIX_C;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user