aj
aj
CC#
Created by aj on 5/11/2025 in #help
Need help writing specification for a task
// using System;
using System.Globalization;

namespace algorithm
{
internal class Program
{
struct Planet
{
public int ox;
public int nt;
public double[] d;
}

static void Main(string[] args)
{
CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;

string[] firstLine = Console.ReadLine().Split();
int n = int.Parse(firstLine[0]);
int m = int.Parse(firstLine[1]);

Planet[] data = new Planet[n];
for (int i = 0; i < n; i++)
{
string[] line = Console.ReadLine().Split();
data[i].ox = int.Parse(line[0]);
data[i].nt = int.Parse(line[1]);

data[i].d = new double[m];
double sum = data[i].ox + data[i].nt;

for (int j = 0; j < m; j++)
{
data[i].d[j] = double.Parse(line[j + 2]);
sum += data[i].d[j];
}

if (data[i].ox < 1 || data[i].ox > 99 ||
data[i].nt < 1 || data[i].nt > 99)
{
continue;
}

bool allInRange = true;
for (int j = 0; j < m; j++)
{
if (data[i].d[j] < 0 || data[i].d[j] > 2)
{
allInRange = false;
}
}

if (!allInRange || Math.Abs(sum - 100.0) > 0.0001)
{
continue;
}
}

int planets = 0;

for (int i = 0; i < n; i++)
{
bool valid = true;

if (data[i].ox >= 19 && data[i].ox <= 24 &&
data[i].nt >= 76 && data[i].nt <= 81)
{
for (int j = 0; j < m; j++)
{
if (data[i].d[j] > 0.5)
{
valid = false;
}
}

if (valid)
{
planets++;
}
}
}

Console.WriteLine(planets);
}
}
}
// using System;
using System.Globalization;

namespace algorithm
{
internal class Program
{
struct Planet
{
public int ox;
public int nt;
public double[] d;
}

static void Main(string[] args)
{
CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;

string[] firstLine = Console.ReadLine().Split();
int n = int.Parse(firstLine[0]);
int m = int.Parse(firstLine[1]);

Planet[] data = new Planet[n];
for (int i = 0; i < n; i++)
{
string[] line = Console.ReadLine().Split();
data[i].ox = int.Parse(line[0]);
data[i].nt = int.Parse(line[1]);

data[i].d = new double[m];
double sum = data[i].ox + data[i].nt;

for (int j = 0; j < m; j++)
{
data[i].d[j] = double.Parse(line[j + 2]);
sum += data[i].d[j];
}

if (data[i].ox < 1 || data[i].ox > 99 ||
data[i].nt < 1 || data[i].nt > 99)
{
continue;
}

bool allInRange = true;
for (int j = 0; j < m; j++)
{
if (data[i].d[j] < 0 || data[i].d[j] > 2)
{
allInRange = false;
}
}

if (!allInRange || Math.Abs(sum - 100.0) > 0.0001)
{
continue;
}
}

int planets = 0;

for (int i = 0; i < n; i++)
{
bool valid = true;

if (data[i].ox >= 19 && data[i].ox <= 24 &&
data[i].nt >= 76 && data[i].nt <= 81)
{
for (int j = 0; j < m; j++)
{
if (data[i].d[j] > 0.5)
{
valid = false;
}
}

if (valid)
{
planets++;
}
}
}

Console.WriteLine(planets);
}
}
}
30 replies
CC#
Created by aj on 5/11/2025 in #help
Need help writing specification for a task
$code
30 replies
CC#
Created by aj on 5/11/2025 in #help
Need help writing specification for a task
and i followed along with code
30 replies
CC#
Created by aj on 5/11/2025 in #help
Need help writing specification for a task
No description
30 replies
CC#
Created by aj on 5/11/2025 in #help
Need help writing specification for a task
so i decided to make a structogram aswell and thats when it started clicking
30 replies
CC#
Created by aj on 5/11/2025 in #help
Need help writing specification for a task
i figured it all out
30 replies
CC#
Created by aj on 5/11/2025 in #help
Need help writing specification for a task
alr! lets give it a shot
30 replies
CC#
Created by aj on 5/11/2025 in #help
Need help writing specification for a task
this is what i came up with
30 replies
CC#
Created by aj on 5/11/2025 in #help
Need help writing specification for a task
In: n∈N, m∈N, planetData∈Data[1..n], Data = (ox:N x nt:N), dangerous∈R[1..n,1..m] Out: livablePlanets∈N Pre: 1≤n≤100 and 1≤m≤10 and ∀i∈[1..n]:((1≤planetData[i].ox≤99) and (1≤planetData[i].nt≤99) and ∀j∈[1..m]:(0 ≤ dangerous ≤ 2)) Post: livablePlanets=COUNT(i=1..n, 19≤planetData[i].ox≤24 and 76≤planetData[i].nt≤81 and ∀j∈[1..m]:( dangerous ≤ 0.5))
30 replies
CC#
Created by aj on 5/11/2025 in #help
Need help writing specification for a task
$code
30 replies
CC#
Created by aj on 5/11/2025 in #help
Need help writing specification for a task
so i came up with a pattern but im having issues getting it to work
30 replies
CC#
Created by aj on 5/11/2025 in #help
Need help writing specification for a task
and its pretty obvious i need to use a counting pattern
30 replies
CC#
Created by aj on 5/11/2025 in #help
Need help writing specification for a task
In: n ∈ N, m ∈ N, oxy ∈ N[1..n] nitro ∈ N[1..n], danger ∈ R[1..n, 1..m]
30 replies
CC#
Created by aj on 5/11/2025 in #help
Need help writing specification for a task
okay so first i declare everything in the input like so
30 replies
CC#
Created by aj on 5/11/2025 in #help
Need help writing specification for a task
Like Counting, and Decision
30 replies
CC#
Created by aj on 5/11/2025 in #help
Need help writing specification for a task
Input: Output: Precondition: Postcondition: and have test cases put out for it and we have to use specific patterns
30 replies
CC#
Created by aj on 5/11/2025 in #help
Need help writing specification for a task
No description
30 replies