Skip to content
Merged
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
99 changes: 93 additions & 6 deletions Lab3/White.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,27 @@ public double Task1(int n)
double averageHeight = 0;

// code here

// PROBLEM ONE---------------------------------------------------------------------------------------------------------------------------------------------START

double answer = 0;

if (n > 0)
{

for (int i = 1; i <=n; i++)

{
double height;
double.TryParse(Console.ReadLine(), out height);
answer += height;
}

averageHeight = answer / n;

}


//---------------------------------------------------------------------------------------------------------------------------------------------
// end

return averageHeight;
Expand All @@ -19,7 +39,22 @@ public double Task2(int n)
double bestResult = 0;

// code here

// PROBLEM TWO---------------------------------------------------------------------------------------------------------------------------------------------START

bestResult = 1000000;

for (int i = 1; i <= n; i++)
{
double h;
double.TryParse(Console.ReadLine(), out h);

if (h < bestResult)
{
bestResult = h;
}
}

//---------------------------------------------------------------------------------------------------------------------------------------------
// end

return bestResult;
Expand All @@ -29,7 +64,19 @@ public int Task3(int n, double limit)
int count = 0;

// code here

// PROBLEM THREE---------------------------------------------------------------------------------------------------------------------------------------------START

for (int i = 0; i < n; i++)
{
double time = double.Parse(Console.ReadLine());

if (time <= limit)
{
count=count+1;
}
}

//---------------------------------------------------------------------------------------------------------------------------------------------
// end

return count;
Expand All @@ -39,7 +86,28 @@ public int Task4(int maxAmount)
int hours = 0;

// code here

// PROBLEM FOUR---------------------------------------------------------------------------------------------------------------------------------------------START

int amount = 0;
amount = int.Parse(Console.ReadLine());

while (amount < maxAmount)
{
if (hours % 5 != 4)
{
amount++;
}

else
{
amount -= 2;
}

hours++;
}


//---------------------------------------------------------------------------------------------------------------------------------------------
// end

return hours;
Expand All @@ -49,10 +117,29 @@ public double Task5(int r, int type)
double area = 0;

// code here

// PROBLEM FIVE---------------------------------------------------------------------------------------------------------------------------------------------START

if (type == 1)
{
area = r * r;
}

else if (type == 2)
{
area = Math.PI * (r * r);
}

if (type == 3)
{
area = ((r * r) * Math.Sqrt(3)) / 4;
}

//---------------------------------------------------------------------------------------------------------------------------------------------
// end

return area;
}
}
}

}

Loading