//левая и правая границы отрезка, количество точек
$a = readline("Левая граница отрезка a = ");
$b= readline("Правая граница отрезка b = ");
$n = readline("Количество точек n = ");
echo "i |x |y \n";
$x = $a;
$dx = ($b - $a) / ($n-1); //расстояние между точками
for ($i = 1; $i <=$n; $i++)
{
$y = sin($x) * atan($x); //вычисление значения функции
echo sprintf("%3d%10.3f%10.3f\n",$i,$x,$y);
$x = $a + $i*$dx; //вычисление значения аргумента
}
private void Start()
{
System.Random r = new System.Random();
int result;
int x = 5, y = 10;
result = r.Next(x, y); // x - минимальное, y - максимальное возможные числа
}
public static void EncryptFile(string inputFile, string outputFile){
using (var rijndael = RijndaelManaged.Create()){
rijndael.GenerateIV();
rijndael.GenerateKey();
using (var inputStream = File.OpenRead(inputFile))
using (var outputStream = new FileStream(outputFile, FileMode.Create, FileAccess.Write))
using (var encStream = new CryptoStream(outputStream, rijndael.CreateEncryptor(), CryptoStreamMode.Write)){
Task.Run(() =>{
double len = inputStream.Length;
while (outputStream.Length < inputStream.Length){
int currentLineCursor = Console.CursorTop;
Console.SetCursorPosition(0, Console.CursorTop);
Console.Write(new string(' ', Console.WindowWidth));
Console.SetCursorPosition(0, currentLineCursor);
Console.Write(String.Format("Завершено на {0}%", Math.Round(((double)outputStream.Length / len * 100), 2)));
Thread.Sleep(100);
}
});
inputStream.CopyTo(encStream);
Console.WriteLine("\nЗавершено!");
}
}
}
Console.ForegroundColor = ConsoleColor.White;
Console.BackgroundColor = ConsoleColor.Green;
Console.Clear();
Console.WriteLine("Hello");
Console.ReadKey();
public partial class Form1 : Form
{
private OpenGL gl;
private float offX = 0;//вращение камеры
private float offY = 100;//высота камеры
private float cameraDist = 200;//дистация камеры от центра
private int maxHeightMap = 50;//максимальная высота гор с 100% яркостью
private float sensivity = 5;//Чувстительность мыши
//для вращения
private int lastX = 0;
private int lastY = 0;
private bool isDrag = false;
int xC = 0;//Количество точек по х
int zC = 0;//Количество точек по y
int[,] points ;//массив высот,
private void openGLControl1_MouseUp(object sender, MouseEventArgs e){
if (e.Button == MouseButtons.Left)
isDrag = false;
}
private void openGLControl1_MouseMove(object sender, MouseEventArgs e)
{
if (isDrag)
{
offX += (e.X - lastX) / sensivity;
offY += (lastY - e.Y) / sensivity;
}
lastX = e.X;
lastY = e.Y;
}
private void openGLControl1_MouseDown(object sender, MouseEventArgs e){
if (e.Button == MouseButtons.Left){
lastX = e.X;
lastY = e.Y;
isDrag = true;
}
}
public Form1(){
InitializeComponent();
gl = this.openGLControl1.OpenGL;
openGLControl1.MouseWheel += openGLControl1_MouseWheel;
gl.ClearColor(1, 1, 1, 0);
}
void openGLControl1_MouseWheel(object sender, MouseEventArgs e){
if (e.Delta < 0 && cameraDist < 500)
cameraDist += 20;
if (e.Delta > 0 && cameraDist > 20)
cameraDist -= 20;
}
private void Form1_Load(object sender, EventArgs e){
var bmp = new Bitmap(Properties.Resources.noise);//Берем изображение шума из ресурсов
xC = bmp.Width;
zC = bmp.Height;
points = new int[xC, zC];
for (int i = 0; i < xC; i++)
for (int j = 0; j < zC; j++){
points[i, j] = (int)(bmp.GetPixel(i, j).GetBrightness() * maxHeightMap);//Генерируем карту высот по яркости пикселем
}
}
public void setColor(int val, OpenGL gl){
double col = (double)val/(double)maxHeightMap * 0.8f;//цвет вершин чем выше тем светлее
gl.Color(col, col, col);
}
private void openGLControl1_OpenGLDraw(object sender, RenderEventArgs args){
gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
var width = openGLControl1.Width;
var height = openGLControl1.Height;
gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
gl.MatrixMode(OpenGL.GL_PROJECTION);
gl.LoadIdentity();
gl.Perspective(60.0f, (double)Width / (double)Height, 0.01, 500.0);
//Вращение камеры
double angleT = (offX%360)*Math.PI/180f;
double vx = xC / 2 + Math.Cos(angleT) * cameraDist;
double vz = zC / 2 + Math.Sin(angleT) * cameraDist;
gl.LookAt(vx, offY%200, vz, xC / 2, maxHeightMap / 2, zC / 2 , 0, 50, 0);
gl.MatrixMode(OpenGL.GL_MODELVIEW);
gl.LoadIdentity();
double color = 0;
//Рисуем карту по треугольникам
for (int x = 0; x < xC-1; x++)
for (int z = 0; z < zC-1; z++){
gl.Begin(OpenGL.GL_TRIANGLES);
setColor(points[x, z], gl);
gl.Vertex(x, points[x, z],z);
setColor(points[x+1, z], gl);
gl.Vertex(x + 1, points[x+1, z],z);
setColor(points[x, z+1], gl);
gl.Vertex(x, points[x, z + 1], z + 1);
gl.End();
gl.Begin(OpenGL.GL_TRIANGLES);
setColor(points[x+1, z], gl);
gl.Vertex(x + 1, points[x + 1, z],z);
setColor(points[x + 1, z+1], gl);
gl.Vertex(x + 1, points[x + 1, z + 1], z + 1);
setColor(points[x , z+1], gl);
gl.Vertex(x, points[x, z + 1],z + 1);
gl.End();
}
}
}
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
int iterationCounter = 0;
while(true){
//todo
iterationCounter++;
if(stopWatch.ElapsedMilliseconds >= 1000){
Console.WriteLine("iterations "+iterationCounter);
break;
}
}
stopWatch.Stop();
(new Thread(() => {
Invoke(new Action(() =>
{
mylabel.Text = "Обработка файла...";
}));
//Тут обработка файла
Invoke(new Action(() =>
{
mylabel.Text = "Обработка файла завершена!";
}));
})).Start();
...
friend = GameObject.FindGameObjectsWithTag("Friend");
foreach (GameObject go in friend)
....
Thread thread = new Thread(() => {
unt_client_recv(client, "127.0.0.1", 25443);
});
var key = "71c5dd47-2ab2-40d4-bb00-4974097af5b6";
var request = WebRequest.Create("https://kinopoiskapiunofficial.tech/api/v2.1/films/300");
request.ContentType = "application/json";
request.Headers["X-API-KEY"] = key;
request.Method = "GET";
using (var stream = request.GetResponse().GetResponseStream()){
List<byte> buff = new List<byte>();
while (true){
int b = stream.ReadByte();
if(b != -1)
buff.Add((byte) b);
else
break;
}
textBox1.Text = Encoding.UTF8.GetString(buff.ToArray());
}
using (var stream = new StreamReader(request.GetResponse().GetResponseStream()))
textBox1.Text = = stream.ReadToEnd();
stingName.Where(s => s.Contains("a")).ToList().ForEach(s => Console.WriteLine(s));