public abstract class Transport {
public int MaxSpeed { get; private set; }
public Transport(int maxSpeed) {
MaxSpeed = maxSpeed;
}
public string Run(int speed)
=> $"Скорость движения транспорта {(speed <= MaxSpeed ? "в пределах нормы" : "выше максимальной")}";
}
public class Car : Transport {
public Car() : base(300) {}
}
public class Bike : Transport {
public Bike() : base(40) {}
}
QProcess process;
process.start("python", QStringList() << "путь_к_файлу.py");
process.waitForFinished();
QString result(process.readAllStandardOutput());
// или если текст на русском
// QString result = QString::fromLocal8Bit(process.readAllStandardOutput()));
coords = input("Введите координаты в формате x.x, y.y ... ").split(",")
x = float(coords[0])
y = float(coords[1])
if x < 0.0:
if y < 0.0:
print("Третий квадрант")
elif y > 0.0:
print("Второй квадрант")
else:
print("На x оси")
elif x > 0.0:
if y > 0.0:
print("Первый квадрант")
elif y < 0.0:
print("Четвертый квадрант")
else:
print("На x оси")
else:
if y == 0:
print("Нулевые координаты")
else:
print("На y оси")
using Process process = Process.Start(new ProcessStartInfo {
FileName = "python",
Arguments = @"path\pyscript.py",
UseShellExecute = false,
RedirectStandardInput = true,
RedirectStandardOutput = true
});
int[] arr = { 1, 2, 3, 4, 5, 6 };
using BinaryWriter writer = new BinaryWriter(process.StandardInput.BaseStream);
Array.ForEach(arr, writer.Write);
writer.Flush();
using BinaryReader reader = new BinaryReader(process.StandardOutput.BaseStream);
int result = reader.ReadInt32();
Console.WriteLine(result);
Console.ReadKey(false);
import os
import sys
stdin = sys.stdin.buffer
stdout = sys.stdout.buffer
def get_int_list():
stdin.seek(0, os.SEEK_END)
n = stdin.tell() // 4
arr = [0] * n
for i in range(n):
arr[i] = int.from_bytes(stdin.read(4), byteorder='little')
return arr
def write_int(i: int):
stdout.write(i.to_bytes(4, byteorder='little'))
nums = get_int_list()
result = sum(nums)
write_int(result)