First Upload
This commit is contained in:
6
2/PDF/debug.log
Normal file
6
2/PDF/debug.log
Normal file
@@ -0,0 +1,6 @@
|
||||
[0912/185130.873:ERROR:crash_report_database_win.cc(469)] failed to stat report
|
||||
[0912/185130.876:ERROR:crash_report_database_win.cc(469)] failed to stat report
|
||||
[0912/185130.906:ERROR:crash_report_database_win.cc(469)] failed to stat report
|
||||
[0912/185130.930:ERROR:crash_report_database_win.cc(469)] failed to stat report
|
||||
[0912/185131.063:ERROR:crash_report_database_win.cc(469)] failed to stat report
|
||||
[0912/185131.106:ERROR:crash_report_database_win.cc(469)] failed to stat report
|
||||
BIN
2/PDF/ex1.c.pdf
Normal file
BIN
2/PDF/ex1.c.pdf
Normal file
Binary file not shown.
BIN
2/PDF/ex2.c.pdf
Normal file
BIN
2/PDF/ex2.c.pdf
Normal file
Binary file not shown.
BIN
2/PDF/ex3.c.pdf
Normal file
BIN
2/PDF/ex3.c.pdf
Normal file
Binary file not shown.
BIN
2/PDF/ex4.c.pdf
Normal file
BIN
2/PDF/ex4.c.pdf
Normal file
Binary file not shown.
BIN
2/PDF/ex5.c.pdf
Normal file
BIN
2/PDF/ex5.c.pdf
Normal file
Binary file not shown.
BIN
2/PDF/libs.h.pdf
Normal file
BIN
2/PDF/libs.h.pdf
Normal file
Binary file not shown.
72
2/ex1.c
Normal file
72
2/ex1.c
Normal file
@@ -0,0 +1,72 @@
|
||||
#include <stdio.h>
|
||||
#include "libs.h"
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Exercise 1
|
||||
// ----------
|
||||
//
|
||||
// General : The program sort 3 numbers by char.
|
||||
//
|
||||
// Input : 3 numbers and char 'U' or 'D'.
|
||||
//
|
||||
// Process : Bubble sort.
|
||||
//
|
||||
// Output : 3 numbers sorted by char.
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Programmer : Cohen Idan
|
||||
// Student No : None
|
||||
// Date : 12.09.2019
|
||||
//---------------------------------------------------------------------------------------
|
||||
void main(void)
|
||||
{
|
||||
char code;
|
||||
short num1,
|
||||
num2,
|
||||
num3,
|
||||
first_num,
|
||||
second_num,
|
||||
third_num,
|
||||
temp_max,
|
||||
temp_min;
|
||||
|
||||
printf("Enter code 'U' or 'D': ");
|
||||
scanf("%c", &code);
|
||||
printf("Enter 3 numbers: ");
|
||||
scanf("%hd%hd%hd", &num1, &num2, &num3);
|
||||
|
||||
first_num = num1;
|
||||
second_num = num2;
|
||||
third_num = num3;
|
||||
|
||||
temp_max = MAX(first_num, second_num);
|
||||
temp_min = MIN(first_num, second_num);
|
||||
second_num = temp_max;
|
||||
first_num = temp_min;
|
||||
if (code == 'D')
|
||||
{
|
||||
second_num = temp_min;
|
||||
first_num = temp_max;
|
||||
}
|
||||
|
||||
temp_max = MAX(second_num, third_num);
|
||||
temp_min = MIN(second_num, third_num);
|
||||
third_num = temp_max;
|
||||
second_num = temp_min;
|
||||
if (code == 'D')
|
||||
{
|
||||
third_num = temp_min;
|
||||
second_num = temp_max;
|
||||
}
|
||||
|
||||
temp_max = MAX(first_num, second_num);
|
||||
temp_min = MIN(first_num, second_num);
|
||||
second_num = temp_max;
|
||||
first_num = temp_min;
|
||||
if (code == 'D')
|
||||
{
|
||||
second_num = temp_min;
|
||||
first_num = temp_max;
|
||||
}
|
||||
|
||||
printf("%hd %hd %hd\n", first_num, second_num, third_num);
|
||||
}
|
||||
55
2/ex2.c
Normal file
55
2/ex2.c
Normal file
@@ -0,0 +1,55 @@
|
||||
#include <stdio.h>
|
||||
#include "libs.h"
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Exercise 2
|
||||
// ----------
|
||||
//
|
||||
// General : The program recognize if is it triangles and the type of triangle.
|
||||
//
|
||||
// Input : 3 numbers.
|
||||
//
|
||||
// Process : The program recognize by angles if is it triangles and the type of triangle.
|
||||
//
|
||||
// Output : '0' - is not a triangle.
|
||||
// '1' - is sharp angled triangle.
|
||||
// '2' - is right angled triangle.
|
||||
// '3' - is blunt angled triangle.
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Programmer : Cohen Idan
|
||||
// Student No : None
|
||||
// Date : 12.09.2019
|
||||
//---------------------------------------------------------------------------------------
|
||||
void main(void)
|
||||
{
|
||||
unsigned short angle1,
|
||||
angle2,
|
||||
angle3,
|
||||
max_angle,
|
||||
sum_angles,
|
||||
type_triangle = ZERO;
|
||||
printf("Enter 3 angels: ");
|
||||
scanf("%hu%hu%hu", &angle1, &angle2, &angle3);
|
||||
|
||||
sum_angles = angle1 + angle2 + angle3;
|
||||
if (sum_angles == SUM_OF_ANGLES_IN_A_TRIANGLE)
|
||||
{
|
||||
max_angle = angle1;
|
||||
max_angle = MAX(MAX(max_angle, angle2), angle3);
|
||||
type_triangle = SHARP_ANGLED_TRIAMGLE;
|
||||
if (max_angle == RIGHT_ANGLE)
|
||||
{
|
||||
type_triangle = RIGHT_ANGLED_TRIAMGLE;
|
||||
if (max_angle > RIGHT_ANGLE)
|
||||
{
|
||||
type_triangle = BLUNT_ANGLED_TRIAMGLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printf("If you got '0' - is not a triangle.\n\
|
||||
If you got '1' - is sharp angled triangle.\n\
|
||||
If you got '2' - is right angled triangle.\n\
|
||||
If you got '3' - is blunt angled triangle.\n\
|
||||
Triangle: %hu\n", type_triangle);
|
||||
}
|
||||
49
2/ex3.c
Normal file
49
2/ex3.c
Normal file
@@ -0,0 +1,49 @@
|
||||
#include <stdio.h>
|
||||
#include "libs.h"
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Exercise 3
|
||||
// ----------
|
||||
//
|
||||
// General : The program performs the formula of the roots.
|
||||
//
|
||||
// Input : 3 numbers (a,b,c from ax^2+bx+c).
|
||||
//
|
||||
// Process : The program performs the formula of the roots.
|
||||
//
|
||||
// Output : 2 numbers (sign and result).
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Programmer : Cohen Idan
|
||||
// Student No : None
|
||||
// Date : 12.09.2019
|
||||
//---------------------------------------------------------------------------------------
|
||||
void main(void)
|
||||
{
|
||||
short num_a,
|
||||
num_b,
|
||||
num_c,
|
||||
delta,
|
||||
sign = ONE,
|
||||
result = ZERO;
|
||||
|
||||
printf("Enter a,b,c from ax^2+bx+c: ");
|
||||
scanf("%hd%hd%hd", &num_a, &num_b, &num_c);
|
||||
|
||||
// Calculate delta
|
||||
delta = (num_b * num_b) - (FOUR * num_a * num_c);
|
||||
result = -num_b / TWO * num_a;
|
||||
if (delta > ZERO)
|
||||
{
|
||||
sign = TWO;
|
||||
result = ZERO;
|
||||
}
|
||||
if (delta < ZERO)
|
||||
{
|
||||
sign = ZERO;
|
||||
result = ZERO;
|
||||
}
|
||||
|
||||
printf("If you got sign '0' - not result\n\
|
||||
If you got sign '1' - one result\n\
|
||||
If you got sign '2' - two results:\nSign: %hd\nResult: %hd\n", sign, result);
|
||||
}
|
||||
54
2/ex4.c
Normal file
54
2/ex4.c
Normal file
@@ -0,0 +1,54 @@
|
||||
#include <stdio.h>
|
||||
#include "libs.h"
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Exercise 4
|
||||
// ----------
|
||||
//
|
||||
// General : The program checks for the logical results of a championship game in
|
||||
// the basket ball.
|
||||
//
|
||||
// Input : 2 numbers (results).
|
||||
//
|
||||
// Process : The program checks for the logical results by conditions.
|
||||
//
|
||||
// Output : '1' if is it True, '0' is false.
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Programmer : Cohen Idan
|
||||
// Student No : None
|
||||
// Date : 12.09.2019
|
||||
//---------------------------------------------------------------------------------------
|
||||
void main(void)
|
||||
{
|
||||
unsigned short result1,
|
||||
result2,
|
||||
difference;
|
||||
BOOLEAN answer = FALSE;
|
||||
|
||||
printf("Enter 2 numbers: ");
|
||||
scanf("%hu%hu", &result1, &result2);
|
||||
|
||||
difference = ABS(result1 - result2);
|
||||
|
||||
if (result1 <= ONE_HUNDRED_FIFTY)
|
||||
{
|
||||
if (result2 <= ONE_HUNDRED_FIFTY)
|
||||
{
|
||||
if (result1 >= FORTY)
|
||||
{
|
||||
if (result2 >= FORTY)
|
||||
{
|
||||
if (difference < SIXTY)
|
||||
{
|
||||
if (difference != ZERO)
|
||||
{
|
||||
answer = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printf("The answer: %hu\n", answer);
|
||||
}
|
||||
89
2/ex5.c
Normal file
89
2/ex5.c
Normal file
@@ -0,0 +1,89 @@
|
||||
#include <stdio.h>
|
||||
#include "libs.h"
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Exercise 5
|
||||
// ----------
|
||||
//
|
||||
// General : The program calculate the final salary by parameters.
|
||||
//
|
||||
// Input : 8 numbers
|
||||
//
|
||||
// Process : The program calculate the final salary by parameters.
|
||||
//
|
||||
// Output : The final salary
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Programmer : Cohen Idan
|
||||
// Student No : None
|
||||
// Date : 12.09.2019
|
||||
//---------------------------------------------------------------------------------------
|
||||
void main(void)
|
||||
{
|
||||
float salary,
|
||||
vetek,
|
||||
hours,
|
||||
kids,
|
||||
temp_kids,
|
||||
temp_hours,
|
||||
ty,
|
||||
tb,
|
||||
t160,
|
||||
t175,
|
||||
final_salary;
|
||||
|
||||
printf("Enter salary: ");
|
||||
scanf("%f", &salary);
|
||||
printf("Enter vetek: ");
|
||||
scanf("%f", &vetek);
|
||||
printf("Enter hours: ");
|
||||
scanf("%f", &hours);
|
||||
printf("Enter kids: ");
|
||||
scanf("%f", &kids);
|
||||
printf("Enter ty: ");
|
||||
scanf("%f", &ty);
|
||||
printf("Enter tb: ");
|
||||
scanf("%f", &tb);
|
||||
printf("Enter t160: ");
|
||||
scanf("%f", &t160);
|
||||
printf("Enter t175: ");
|
||||
scanf("%f", &t175);
|
||||
|
||||
temp_kids = kids;
|
||||
temp_hours = hours;
|
||||
final_salary = salary;
|
||||
|
||||
if (vetek > TEN)
|
||||
{
|
||||
final_salary += (int)((double)final_salary * ONE_HUNDRED_AND_TEN_PERCENT);
|
||||
}
|
||||
|
||||
temp_kids -= THREE;
|
||||
if (temp_kids > ZERO)
|
||||
{
|
||||
if (temp_kids > THREE)
|
||||
{
|
||||
final_salary += ((temp_kids - THREE) * tb) +
|
||||
(temp_kids - (temp_kids - THREE)) * ty;
|
||||
}
|
||||
else
|
||||
{
|
||||
final_salary += (temp_kids * ty)
|
||||
}
|
||||
}
|
||||
|
||||
temp_hours -= ONE_HUNDRED_SIXTY;
|
||||
if (temp_hours > ZERO)
|
||||
{
|
||||
if (temp_hours > FIFTEEN)
|
||||
{
|
||||
final_salary += ((temp_hours - FIFTEEN) * t175) +
|
||||
(temp_hours - (temp_hours - FIFTEEN)) * t160;
|
||||
}
|
||||
else
|
||||
{
|
||||
final_salary += (temp_hours * t160);
|
||||
}
|
||||
}
|
||||
|
||||
printf("The salary: %f\n", final_salary);
|
||||
}
|
||||
24
2/libs.h
Normal file
24
2/libs.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#define MAX(a,b) a > b ? a : b
|
||||
#define MIN(a,b) a < b ? a : b
|
||||
#define SUM_OF_ANGLES_IN_A_TRIANGLE 180
|
||||
#define RIGHT_ANGLE 90
|
||||
#define ZERO 0
|
||||
#define SHARP_ANGLED_TRIAMGLE 1
|
||||
#define RIGHT_ANGLED_TRIAMGLE 2
|
||||
#define BLUNT_ANGLED_TRIAMGLE 3
|
||||
#define FOUR 4
|
||||
#define TWO 2
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#define POSITIVE_DIFFERENCE(a,b) MAX(a,b) - MIN(a,b)
|
||||
#define BOOLEAN unsigned short
|
||||
#define ABS(a) (a > 0) ? a : -a
|
||||
#define TEN 10
|
||||
#define THREE 3
|
||||
#define ONE_HUNDRED_AND_TEN_PERCENT 1.1
|
||||
#define ONE_HUNDRED_SIXTY 160
|
||||
#define FIFTEEN 15
|
||||
#define ONE_HUNDRED_FIFTY 150
|
||||
#define FORTY 40
|
||||
#define SIXTY 60
|
||||
#define ONE 1
|
||||
20
2/test.asm
Normal file
20
2/test.asm
Normal file
@@ -0,0 +1,20 @@
|
||||
mov bh, 0
|
||||
mov ah, cl
|
||||
begin:
|
||||
cmp ch, ah ; if ah > ch jump to lower
|
||||
jg lower
|
||||
mov al, ah
|
||||
mov ah, ch
|
||||
mov ch, al
|
||||
lower:
|
||||
cmp bh, ch ; if ch < bh jump to finish
|
||||
jg finish
|
||||
mov bh, ch
|
||||
finish:
|
||||
mov ch, dl
|
||||
mov dl, dh
|
||||
mov dh, 0
|
||||
cmp ch, 0
|
||||
je the_end ; if ch == 0 jump to the_end
|
||||
jmp begin
|
||||
the_end:
|
||||
Reference in New Issue
Block a user