Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
68 changes: 54 additions & 14 deletions Lab1/Blue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@ public bool Task1(int a, int b)
bool answer = false;

// code here
// а и б одного знака - проверка, одно из них 0 - фолс
if ((a > 0 && b > 0) || (a < 0 && b < 0)) { answer = true; }
else if (a == 0 || b == 0) { answer = false; }
// end

// end

return answer;
return answer;
}
public bool Task2(double d)
{
bool answer = false;

// code here

int dd = (int)d;
double f = Math.Abs(d - dd);
if( f >= 0.0001) { answer = true; }
// end

return answer;
Expand All @@ -27,7 +31,8 @@ public bool Task3(int a, int b)
bool answer = false;

// code here

if (b == 0) { answer = false; }
else if (a % b == 0) { answer = true; }
// end

return answer;
Expand All @@ -37,27 +42,41 @@ public double Task4(double d, double f, double g)
double answer = 0;

// code here
double dd = Math.Abs(d);
double ff = Math.Abs(f);
double gg = Math.Abs(g);

// end
if (dd >= ff && dd >= gg) { answer = d; }
else if (ff >= dd && ff >= gg) { answer = f; }
else { answer = g; }

return answer;
// end

return answer;
}
public double Task5(double x)
{
double answer = 0;

// code here

if (x <= -1) { answer = 0; }
else if (-1 < x && x <= 0 ) { answer = x + 1; }
else { answer = 1; }


// end

return answer;
return answer;
}
public bool Task6(double circleS, double squareS)
{
bool answer = false;

// code here

double R = Math.Sqrt(circleS / double.Pi);
double side = Math.Sqrt(squareS);
if (2 * R <= side) { answer = true; }
// end

return answer;
Expand All @@ -68,17 +87,38 @@ public double Task7(double d, double f)
int answer = 0;

// code here

// end

return answer;
if (Math.Abs(d) < Math.Abs(f))
{
if (d > 0) { answer = -1; }
}
else
{
if (f > 0) { answer = 1; }
}
// end

return answer;
}
public bool Task8(int a, int b, int c)
{
bool answer = false;

// code here

//1. все ровно без 1oй монеты короля
//sum - общая вместимость
int sum = a + b + c;
int aBig = a / 2;
int bBig = b / 2;
int cBig = c / 2;

// x - кол-во монет в мешках, x>=1
//максимум в 3х мешках по x монет -- x<=aBig;bBig;cBig
// кол-во всего монет - 3x + 1( 1 - та монета, которую от себя король может добавить
//проверка на то что в мешке не 0 морнет
//надо: 1. x>=1, 2. x<=aBig;bBig;cBig, 3. sum >= 2x(если монеты 2, то может добавить король)
//1 монета == false
// влияет ли вместимость мешка младшего ребенка на кол-во монет у других?..

// end

return answer;
Expand Down
78 changes: 66 additions & 12 deletions Lab1/Green.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ public bool Task1(double d)
bool answer = false;

// code here

if (Math.Abs(d) >= 1)
{
answer = true;
}
// end

return answer;
Expand All @@ -17,7 +20,8 @@ public bool Task2(double d, double f)
bool answer = false;

// code here

double c = (d + f) / 2;
if (c > 0) { answer = true; }
// end

return answer;
Expand All @@ -27,7 +31,11 @@ public bool Task3(int a, int b)
bool answer = false;

// code here

int A = Math.Abs(a);
int B = Math.Abs(b);
int AB = (A + B) / 2;
int sum = a + b;
if (sum > AB) { answer = true; }
// end

return answer;
Expand All @@ -37,7 +45,8 @@ public int Task4(int a, int b, int c)
int answer = 0;

// code here

int v = Math.Max(Math.Max(a, b), c);
answer = v;
// end

return answer;
Expand All @@ -47,28 +56,33 @@ public double Task5(double x)
double answer = 0;

// code here
if (Math.Abs(x) > 1) { answer = 0; }
else if (Math.Abs(x) <= 1) { answer = x * x - 1; }
// end

// end

return answer;
return answer;
}
public bool Task6(double x, double y)
{
bool answer = false;

// code here
if (y < 0) { answer = false; }
else if ((x < 0) && (y <= 1 + x)) { answer = true; }
else if ( (x >= 0) && (y <= 1 - x) ) { answer = true; }
// end

// end

return answer;
return answer;
}

public bool Task7(int n)
{
bool answer = true;

// code here

if (n < 0) { answer = false; }
else if (n % 2 == 0) { answer = false; }

// end

return answer;
Expand All @@ -78,7 +92,47 @@ public bool Task8(int X, int Y)
bool answer = false;

// code here

//встает на данный момент в 14 часов дня
int getup = 14;
//на данный момент ложится в 4 часа ночи ( в минутах)
int startsleep = 4 * 60;

//каждое утро дыхательные практики смещают время подъёма на -1 час
//дни в когда пьет чай - 0,2,4,... (через день), засыпает наа Y минут раньше
//итоговое время подъема после X дней
int resultgetup = getup - X;
if (resultgetup < 0) { resultgetup = 0; }
//раньше полуночи не вставать

//кол-во дней когда пила чай (примерно (X+1)/2 или X/2(если четное Х), но лучше Х+1)
int dayswithtea = (X + 1) / 2;
//смещение времени сна в минутах
int changesleep = dayswithtea * Y;
int result = startsleep - changesleep;
if (result < 0) { result = 0; }
//раньше полуночи не ложится
//проверить длительность сна
//посчитать разницу в минутах между подъемом и сном
//время пробуждения в минуты переведуц
int resulttime = resultgetup * 60;
//если время подъема больше времени сна, считаю разницу
int sleepduration = resulttime - result;
if (sleepduration < 0) { sleepduration += 24 * 60; }
//если перескочили через полуночь

//проверка сна маши (7*60=420, 9*60=540)
bool sleep = false;
bool wakeup = false;
if ((sleepduration >= 7 * 60) && (sleepduration <= 9 * 60)) { sleep = true; }
//if (resultgetup <= 7) { wakeup = true; }
//bool sleepOk = sleepduration >= 420 && sleepduration <= 540;
// Встает ли Маша не позже 7 утра?
//bool wakeUpOk = resultgetup <= 7;

if (sleep /*&& wakeup*/)
{
answer = true;
}
// end

return answer;
Expand Down
9 changes: 5 additions & 4 deletions Lab1/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ public class Program
{
public static void Main()
{
//White white = new White();
//Console.WriteLine(white.Task1(1.2));
//Console.WriteLine(white.Task2(2));
//Console.WriteLine(white.Task3(2.5, 1.89));
Blue blue = new Blue();
Console.WriteLine(blue.Task1(1, 2));
Console.WriteLine(blue.Task2(2));
Console.WriteLine(blue.Task3(2, 1));
//Console.WriteLine(white.Task4(-2.5, 1.89));
//Console.WriteLine(white.Task5(0.5));
//Console.WriteLine(white.Task6(2.5, 1.89, 3));
Console.WriteLine(blue.Task7(2, 1));
}
}
}
41 changes: 27 additions & 14 deletions Lab1/White.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Lab1
using System.ComponentModel.Design;

namespace Lab1
{
public class White
{
Expand All @@ -7,27 +9,30 @@ public bool Task1(double d)
bool answer = false;

// code here

if (d > 0) { answer = true; }
// end

return answer;
return answer;
}
public bool Task2(int n)
{
bool answer = false;

// code here
if ((n % 2) == 0) { answer = true;}// если н четно - тру
else { answer = false; } // в противном случае - фолс ( надо ли перед ансвер бул ставить?

// end

return answer;
return answer;
}
public int Task3(int a, int b)
{
int answer = 0;

// code here

if (a >= b) { answer = a; }
else { answer = b; }
// end

return answer;
Expand All @@ -37,7 +42,8 @@ public double Task4(double d, double f)
double answer = 0;

// code here

if ((d * d) > (f * f)) { answer = d; }
else { answer = f; }
// end

return answer;
Expand All @@ -47,7 +53,8 @@ public double Task5(double x)
double answer = 0;

// code here

if (Math.Abs(x) > 1 ) { answer = 1; }
else { answer = x; }
// end

return answer;
Expand All @@ -57,7 +64,7 @@ public bool Task6(double x, double y, double r)
bool answer = false;

// code here

if (Math.Abs(x * x + y * y - r * r) <= (1.0 / 10000)) { answer = true; }
// end

return answer;
Expand All @@ -66,19 +73,25 @@ public bool Task6(double x, double y, double r)
public bool Task7(int n)
{
bool answer = false;

// code here

// end

return answer;
int s = n * n;
if ((s-n) > (2*n))
{
if (n%2 == 0) { answer = true; }
}
// end

return answer;
}
public bool Task8(double L, int T, int M)
{
bool answer = false;

// code here

if (L <= 30 && (T + M) >= 5 && M % 2 == 0)
{
answer = true;
}
// end

return answer;
Expand Down
Loading