Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherinko comp mat 1 #41

Open
wants to merge 45 commits into
base: for_pullr
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
33b3715
update lect 10
mecchmatProjects Dec 8, 2020
a0d7671
update lect 11
mecchmatProjects Dec 8, 2020
79856df
додав запитання по курсу 2020
mecchmatProjects Dec 8, 2020
e44c867
Merge pull request #36 from mecchmatProjects/for_pullr
mecchmatProjects Feb 5, 2021
e7d69c4
Updates to 2021
Feb 5, 2021
8fb042d
remove docs in 11
Feb 5, 2021
1408041
small fixes to tasks 1.2 and 1.3
mecchmatProjects Feb 7, 2021
83be260
update task1_2 pdf
mecchmatProjects Feb 9, 2021
f92a49e
add projects for 2021 statistics
mecchmatProjects Feb 11, 2021
015b318
Delete 2021_projects.docx
mecchmatProjects Feb 11, 2021
1b1194f
Update README.md
mecchmatProjects Feb 11, 2021
deed0cd
Add files via upload
mecchmatProjects Feb 15, 2021
9e74a0b
update lect 04
mecchmatProjects Feb 26, 2021
17032f0
update Lect05
mecchmatProjects Feb 26, 2021
d11135e
update lect 06
mecchmatProjects Feb 26, 2021
98408d0
remove extra tasks02
Mar 1, 2021
278bfee
Add files via upload
mecchmatProjects Mar 14, 2021
170cda3
add tasks for memory(C pointers)
mecchmatProjects Mar 15, 2021
a6b76ce
Add files via upload
mecchmatProjects Mar 16, 2021
d55aca7
Add files via upload
mecchmatProjects Mar 16, 2021
69cd987
Delete tasks4.pdf
mecchmatProjects Mar 22, 2021
3042927
add task 4.0
mecchmatProjects Mar 22, 2021
cc904cb
Delete tasks5.pdf
mecchmatProjects Mar 22, 2021
0c43788
Add files via upload
mecchmatProjects Mar 22, 2021
0d29dec
Add files via upload
mecchmatProjects Mar 30, 2021
20ee332
add task06 -string + text files
mecchmatProjects Apr 6, 2021
0f6bcc2
Add files via upload
mecchmatProjects Apr 13, 2021
ad0ff1a
add tasks09 -inheritance
mecchmatProjects Apr 19, 2021
3868366
add tasks10 for exceptions
mecchmatProjects Apr 26, 2021
4dca536
add tasks11
mecchmatProjects May 11, 2021
34dabf6
fix tasks11
mecchmatProjects May 11, 2021
2d32451
Add files via upload
mecchmatProjects May 17, 2021
490adb8
add tasks_stl2
mecchmatProjects May 19, 2021
8b5b4ad
Add files via upload
mecchmatProjects Aug 19, 2021
1d314da
add manual - pt.1
mecchmatProjects Aug 19, 2021
2001170
Update README.md
mecchmatProjects Aug 19, 2021
12ffb5a
update lect 1
mecchmatProjects Sep 8, 2021
d3057da
update lect0
mecchmatProjects Sep 8, 2021
cadc1e3
add projects 2021 autemn
mecchmatProjects Sep 30, 2021
f387a92
add C++ manual pdf
mecchmatProjects Nov 4, 2021
fb8c5d5
add Rational class
mecchmatProjects Nov 15, 2021
40339c3
Запитання по курсу 2021
mecchmatProjects Dec 7, 2021
42d286e
some fixes
mecchmatProjects Feb 18, 2022
7de751e
some fixes to slides
mecchmatProjects May 4, 2022
bb090ff
update lect2
mecchmatProjects Sep 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed 2021_DoslidBibl.docx
Binary file not shown.
Binary file added 2021_proj_autemn.pdf
Binary file not shown.
Binary file added 2021_projects_spring.pdf
Binary file not shown.
Binary file modified Lect01/CppTutorUkr0.ppt
Binary file not shown.
4 changes: 2 additions & 2 deletions Lect01/Hello/Farenheit.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ int farenheit(){ // òî÷êà âõîäó
float F, C; //âèçíà÷àºìî â³äðàçó äâ³ ä³éñí³ – çì³íí³ ‘F’ òà ‘C’
printf("F="); // âèâîäèìî ï³äêàçêó äëÿ êîðèñòóâà÷à
int res = scanf("%f", &F); // ââåäåííÿ çì³ííî¿ ‘F’
if (res==0){
if (res==1){
C=(F-32)*5/9; /* Îá÷èñëåííÿ çà ôîðìóëîþ */
printf("Celsius C=%e\n",C); /* âèâåäåííÿ çíà÷åííÿ çì³ííî¿ ‘C’ â íàóêîâîìó ôîðìàò³ */
printf("Celsius C=%e\n",C); /* âèâåäåííÿ çíà÷åííÿ çì³ííî¿ ‘C’ â íàóêîâîìó ôîðìàò³ */ x=0.12e02
}
return res;
}
Expand Down
20 changes: 20 additions & 0 deletions Lect02/ByteBites.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Java програма для типу byte
class ByteBites{
public static void main(String args[]){
byte a = 126;
// byte is 8 bit value
System.out.println(a);
a++;
System.out.println(a);
a++;
System.out.println(a); ////Відбудеться циклічний проход по інтервалу
a++;
System.out.println(a);
System.out.printf("%d \n",a);
int b = (a>>2);
int b1 = (a<<2);
int b2 = (a>>>2);

System.out.printf("%d %d %d",b,b1,b2);
}
}
35 changes: 35 additions & 0 deletions Lect02/Calculator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
class Calculator {
public static void main(String[] args) {
char operator;
Double number1, number2, result;

Scanner scanner = new Scanner(System.in);
System.out.print("Enter operator (either +, -, * or /): ");
operator = scanner.next().charAt(0);
System.out.print("Enter number1 and number2 respectively: ");
number1 = scanner.nextDouble();
number2 = scanner.nextDouble();

switch (operator) {
case '+':
result = number1 + number2;
System.out.print(number1 + "+" + number2 + " = " + result);
break;
case '-':
result = number1 - number2;
System.out.print(number1 + "-" + number2 + " = " + result);
break;
case '*':
result = number1 * number2;
System.out.print(number1 + "*" + number2 + " = " + result);
break;
case '/':
result = number1 / number2;
System.out.print(number1 + "/" + number2 + " = " + result);
break;
default:
System.out.println("Invalid operator!");
break;
}
}
}
Binary file modified Lect02/CppTutorUkr1.ppt
Binary file not shown.
69 changes: 69 additions & 0 deletions Lect02/InitialValues2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
public class InitialValuesZ {
boolean bool = true;
char ch = ‘x‘;
byte b = 47;
short 5 = Oxff;
int i = 999;
long lng = 1;
float f = 3.14f;
double d = 3.14159;
}

// housekeeping/MethodInit.java
public class MethodInit {
int i = f();
int f() { return 11; }
}

// housekeeping/MethodInit2.java
public class MethodInit2 {
int i = f();
int j = g(1);
int f() { return 11; }
int g(int n) { return n * 10; }
}

public class MethodInit3 {
//- int j = g(i); // Illegal forward reference
int i = f();
int f() { return 11; }
int g(int n) { return n * 10; }
}

public class Counter {
int i;
Counter() { i = 7; }
// ...
}


class Window {
Window(int marker) {
System.out.println("Window(” + marker + ”)”);
}
}
class House {
Window w1 = new Window(1); // Before constructor
House() {
// Show that we’re in the constructor:
System.out.println("House()");
w3 = new Window(33); // Reinitialize w3
}
Window w2 = new Window(2); // After constructor
void f() { System.out.println(”f()”); }
Window w3 = new Window(3); // At end
}
public class OrderOfInitialization {
public static void main($tring[] args) {
House h = new House();
h.f(); // Shows that construction is done
}
/* Output:
Window(1)
Window(2)
Window(3)
House()
Window(33)
f()
*/

Binary file added Lect02/JavaTutorUkr1.ppt
Binary file not shown.
Binary file added Lect02/JavaTutorUkr1_2.ppt
Binary file not shown.
12 changes: 12 additions & 0 deletions Lect02/L2_1_SimpleConstructor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Simple {
//no-arg constructor (конструктор по замовченню)
Simple() { // Конструктор
System.out.print("Constructor!");
}
}
public class L2_1_SimpleConstructor {
public static void main(String[] args) {
for(int i = 0; i < 3; i++)
new Simple();
}
}
17 changes: 17 additions & 0 deletions Lect02/L2_2NoSimpleTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class NoSimpleClass {
int m;
NoSimpleClass(int i) {}
NoSimpleClass(double d) {}
}

public class L2_2NoSimpleTests {
public static void main(String[] args) {
//- NoSimpleClass b = new NoSimpleClass(); // No default
NoSimpleClass b2 = new NoSimpleClass(1);
NoSimpleClass b3 =new NoSimpleClass(1.0);
//NoSimpleClass b4 =new NoSimpleClass(b3);// Немає копіювання
NoSimpleClass b5 =b2; // b2 те саме що b5 (b5.m == b2.m)
b5.m =2;
System.out.printf("B5.m=%d , B2.m=%d", b5.m,b2.m);
}
}
31 changes: 31 additions & 0 deletions Lect02/L2_3OrderOfInitialization.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
class Window {
Window(int marker) {
System.out.println("Window(" + marker + ")");
}
}
class House {
Window w1 = new Window(1); //Перед
House() {
// Конструктор:
System.out.println("House()");
w3 = new Window(33); //Реініціалізація w3
}
Window w2 = new Window(2); // Після
void f() { System.out.println("f()"); }
Window w3 = new Window(3); // В кінці
}

public class L2_3OrderOfInitialization {
public static void main(String[] args) {
House h = new House();
h.f(); // Виклик методу
}
}
/* Результат:
Window(1)
Window(2)
Window(3)
House()
Window(33)
f()
*/
29 changes: 29 additions & 0 deletions Lect02/L2_4TerminationCondition.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class Book {
boolean checkedOut = false;
Book(boolean checkOut) {
checkedOut = checkOut;
}
void checkIn() {
checkedOut = false;
}

@Override
public void finalize() {
if(checkedOut)
System.out.println("Error: checked out");
// або
//super.finalize(); // Call the base-class version
}
}

public class L2_4TerminationCondition {
public static void main(String[] args) {
Book novel = new Book(true);
// Коректна очистка
novel.checkIn();
// Створили посилання, забули прибрати:
new Book(true);
//Викликали збирач мусора:
System.gc();
}
}
72 changes: 72 additions & 0 deletions Lect02/L2_5StaticInitialization.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
class Bowl {
Bowl(int marker) {
System.out.println("Bowl(" + marker + ")");
}
void f1(int marker) {
System.out.println("f1(" + marker + ")");
}
}

class Table {
static Bowl bowll = new Bowl(1);
Table() {
System.out.println("Table()");
bowl2.f1(1);
}
void f2(int marker) {
System.out.println("f2(" + marker + ")");
}

static Bowl bowl2 = new Bowl(2);
}

class Cupboard {
Bowl bowl3 = new Bowl(3);
static Bowl bowl4 = new Bowl(4);
Cupboard() {
System.out.println("Cupboard()");
bowl4.f1(2);
}
void f3(int marker) {
System.out.println("f3(" + marker + ")");
}
static Bowl bowl5 = new Bowl(5);
}

public class L2_5StaticInitialization {

public static void main(String[] args) {
System.out.println("main creating new Cupboard()");
new Cupboard();
System.out.println("main creating new Cupboard()");
new Cupboard();
table.f2(1);
cupboard.f3(1);
}
static Table table = new Table(); // 1st Table -> Bowl1,Bowl2
static Cupboard cupboard = new Cupboard();
}

/*
2_5StaticInitialization
Bowl(1)
Bowl(2)
Table()
f1(1)
Bowl(4)
Bowl(5)
Bowl(3)
Cupboard()
f1(2)
main creating new Cupboard()
Bowl(3)
Cupboard()
f1(2)
main creating new Cupboard()
Bowl(3)
Cupboard()
f1(2)
f2(1)
f3(1)

*/
35 changes: 35 additions & 0 deletions Lect02/L5_6ExplicitStatic.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@


class Cup {
Cup(int marker) {
System.out.println("Cup(" + marker + ")");
}
void f(int marker) {
System.out.println("f(" + marker + ")");
}
}

class Cups {
static Cup cup1;
static Cup cup2;
static {
cup1 = new Cup(1);
cup2 = new Cup(2);
}
Cups() {
System.out.println("Cups()");
}
}


public class L5_6ExplicitStatic {
static int i;
static { i = 47;}
public static void main(String[] args) {
System.out.println("Inside main()");
Cups.cup1.f(99); // [1]
}
static Cups cups1 = new Cups();
static Cups cups2 = new Cups();
}

16 changes: 16 additions & 0 deletions Lect02/Operation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Operation{  
 int data=50;  

 void change(int data){  
 data=data+100;//changes will be in the local variable only  
}

public static void main(String args[]){  

   Operation op=new Operation();  

   System.out.println("before change "+op.data);  
   op.change(500);  
   System.out.println("after change "+op.data);  
 }  
}
15 changes: 15 additions & 0 deletions Lect02/Operation2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Operation2{  
 int data=50;  

 void change(Operation2 op){  
 op.data=op.data+100;//changes will be in the instance variable  
}  

 public static void main(String args[]){  
   Operation2 op=new Operation2();  
   System.out.println("before change "+op.data);  
   op.change(op);//passing object  
   System.out.println("after change "+op.data);  
 }  

}
21 changes: 21 additions & 0 deletions Lect02/PrimitiveTypes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Java program для роботи з примітивними типами
class PrimitiveTypes{
public static void main(String args[]){
char a = 'G'; // визначаємо символ
int i=89; //Цілий тип (used for numeric values )          
byte b = 4; /* можна використати byte або short якщо потрібно заощадити память
Наступне присвоєння–омилка (larger than byte range )*/
// byte b1 = 7888888955;*/
short s = 56;
long L1 = 0xFEED1234L; // 64-бітне число в 16-річній формі
double d = 4.355453532; // по замовченню дійсне число - тип double
float f = 4.7333434f; // для типу float вказуємо суфікс 'f'
System.out.println("char: " + a);
System.out.println("integer: " + i);
System.out.println("byte: " + b);
System.out.println("short: " + s);
System.out.println("float: " + f);
System.out.println("double: " + d);
System.out.printf("long: %d, %x" , L1, L1);
}
}
Loading