Compare commits
5 Commits
41ad598b79
...
14c58d0cc4
Author | SHA1 | Date |
---|---|---|
|
14c58d0cc4 | |
|
afc13cf9f8 | |
|
e910ee6e4d | |
|
6ab6cc17db | |
|
25173d66d1 |
|
@ -1,7 +1,17 @@
|
||||||
public class Lab1 {
|
public class Lab1 {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println( (double) 0 / 0 );
|
// char c = 'a' + '1';
|
||||||
System.out.println( Math.sqrt(-1) );
|
char c = 97;
|
||||||
|
// char c = '1';
|
||||||
|
System.out.println(c);
|
||||||
|
System.out.println((int) c);
|
||||||
|
c++;
|
||||||
|
System.out.println(c);
|
||||||
|
System.out.println((int) c);
|
||||||
|
System.out.println((double)'1'/'3');
|
||||||
|
|
||||||
|
// System.out.println( (double) 0 / 0 );
|
||||||
|
// System.out.println( Math.sqrt(-1) );
|
||||||
double s = 0;
|
double s = 0;
|
||||||
/*for (int i = 1; i <= 3; i++) { // 1) <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> i = 1, 2) <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <= 3, 3) <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 䳿 <EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
/*for (int i = 1; i <= 3; i++) { // 1) <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> i = 1, 2) <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <= 3, 3) <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 䳿 <EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
||||||
System.out.println(i); // 4) <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD> 1, 5) <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2
|
System.out.println(i); // 4) <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD> 1, 5) <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2
|
||||||
|
@ -12,23 +22,37 @@ public class Lab1 {
|
||||||
for (int i = 0; i < array.length; i++) {
|
for (int i = 0; i < array.length; i++) {
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
final int A = -1;
|
final int A = -3;
|
||||||
final int B = 1;
|
final int B = 0;
|
||||||
final int N = 2;
|
final int N = 2;
|
||||||
final int M = 2;
|
final int M = 2;
|
||||||
|
|
||||||
final int C = 1;
|
final int C = 1;
|
||||||
|
// boolean wasDivisionByZero = false;
|
||||||
for (int i = A; i <= N; i++) {
|
// todo char
|
||||||
if (i + C == 0) { // todo optimize
|
// todo[clear code] think about avoiding brackets
|
||||||
|
if ((A <= -C && -C <= N) || (B <= 0 && 0 <= M)) {
|
||||||
|
System.out.println("Division by zero!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/*myLabel:*/for (int i = A; i <= N /*&& !wasDivisionByZero*/; i++) {
|
||||||
|
/*if (i + C == 0) { // todo optimize
|
||||||
System.out.println("Division by zero!");
|
System.out.println("Division by zero!");
|
||||||
|
wasDivisionByZero = true;
|
||||||
break; //todo flag vs return;
|
break; //todo flag vs return;
|
||||||
}
|
}*/
|
||||||
for (int j = B; j <= M; j++) {
|
for (int j = B; j <= M; j++) {
|
||||||
s += (double) (i + j) / (i + C);
|
/*if (j == 0) {
|
||||||
|
System.out.println("Division by zero!");
|
||||||
|
return;
|
||||||
|
// wasDivisionByZero = true;
|
||||||
|
// break myLabel;
|
||||||
|
}*/
|
||||||
|
s += (double) (i / j) / (i + C);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// if (!wasDivisionByZero) {
|
||||||
System.out.println("s = " + s);
|
System.out.println("s = " + s);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
public class Lab2 {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
int[] array = {1, 2, 3};
|
||||||
|
/*for (int i = 0; i < array.length; i++) {
|
||||||
|
if (i % 2 == 0) {
|
||||||
|
System.out.println("!" + array[i]);
|
||||||
|
} else {
|
||||||
|
System.out.println("?" + array[i]);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
for (int i = 0; i < array.length; i+=2) {
|
||||||
|
System.out.println("!" + array[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 1; i < array.length; i+=2) {
|
||||||
|
System.out.println("?" + array[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// зубчасті матриці
|
||||||
|
int[][] matrix = {
|
||||||
|
{1, 2},
|
||||||
|
{3}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue