Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
38
Task/Euler-method/C-sharp/euler-method.cs
Normal file
38
Task/Euler-method/C-sharp/euler-method.cs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
|
||||
namespace prog
|
||||
{
|
||||
class MainClass
|
||||
{
|
||||
const float T0 = 100f;
|
||||
const float TR = 20f;
|
||||
const float k = 0.07f;
|
||||
readonly static float[] delta_t = {2.0f,5.0f,10.0f};
|
||||
const int n = 100;
|
||||
|
||||
public delegate float func(float t);
|
||||
static float NewtonCooling(float t)
|
||||
{
|
||||
return -k * (t-TR);
|
||||
}
|
||||
|
||||
public static void Main (string[] args)
|
||||
{
|
||||
func f = new func(NewtonCooling);
|
||||
for(int i=0; i<delta_t.Length; i++)
|
||||
{
|
||||
Console.WriteLine("delta_t = " + delta_t[i]);
|
||||
Euler(f,T0,n,delta_t[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Euler(func f, float y, int n, float h)
|
||||
{
|
||||
for(float x=0; x<=n; x+=h)
|
||||
{
|
||||
Console.WriteLine("\t" + x + "\t" + y);
|
||||
y += h * f(y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue