Skip to content

Commit 88d4c77

Browse files
committed
New updates
1 parent 1f4d25c commit 88d4c77

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

CSharp/Test/Program.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
namespace Test;
2+
3+
class Program
4+
{
5+
public int foo(int[] x, int a, int b, int i, int j)
6+
{
7+
int k = j;
8+
int ct = 0;
9+
10+
while (k > i - 1)
11+
{
12+
if ((x[k] <= b) && !(x[k] <= a))
13+
{
14+
ct = ct + 1;
15+
}
16+
17+
k = k - 1;
18+
}
19+
20+
return ct;
21+
}
22+
23+
static void Main(string[] args)
24+
{
25+
int[] x = new int[] { 11, 10, 10, 5, 10, 15, 20, 10, 7, 11 };
26+
27+
Program program = new Program();
28+
29+
Console.WriteLine(program.foo(x, 8, 18, 3, 6));
30+
Console.WriteLine(program.foo(x, 10, 20, 0, 9));
31+
Console.WriteLine(program.foo(x, 8, 18, 6, 3));
32+
Console.WriteLine(program.foo(x, 20, 10, 0, 9));
33+
Console.WriteLine(program.foo(x, 6, 7, 8, 8));
34+
}
35+
}

CSharp/Test/Test.csproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
</Project>

JavaScript/Arrays/test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
function foo(x, a, b, i, j) {
2+
let k = j;
3+
let ct = 0;
4+
5+
while (k > i - 1) {
6+
if (x[k] <= b && !x[k] <= a) {
7+
ct++;
8+
}
9+
10+
k--;
11+
}
12+
13+
return ct;
14+
}
15+
16+
const x = [11, 10, 10, 5, 10, 15, 20, 10, 7, 11];
17+
18+
console.log(foo(x, 8, 18, 3, 6));
19+
console.log(foo(x, 10, 20, 0, 9));
20+
console.log(foo(x, 8, 18, 6, 3));
21+
console.log(foo(x, 20, 10, 0, 9));
22+
console.log(foo(x, 6, 7, 8, 8));

0 commit comments

Comments
 (0)