1)
program fantscrin;
var s:string; i, plus, minus:integer;
begin
write('Введите строку:'); readln(s);
plus:= 0;
minus:= 0;
for i:=1 to length(s) do
if s[i] = '+' then plus := plus + 1;
if s[i] = '-' then minus := minus + 1;
end;
writeln;
if plus > minus then for i:=1 to plus do
write('+')
else if plus < minus then for i:=1 to minus do
write('-')
else write('Кол-во знаков одинаковое!');
end.
2)
var y,x,b,e:real; i:integer;
write('Введите число b:'); readln(b);
e:= 2.7;
x:= 0;
writeln(' y | x ');
writeln('');
while x <= 10 do
if x < 3 then
y:= Exp(x * Ln(e)) + 1 / (x + 1);
writeln(y:6:5, ' | ', x:6:5)
if x = 3 then
y:= Sin(x) + sqrt(x);
writeln(y:6:5, ' | ', x:6:5);
if x > 3 then
y:= Cos(x) + Abs(b);
x:= x + 0.5;
1)
program fantscrin;
var s:string; i, plus, minus:integer;
begin
write('Введите строку:'); readln(s);
plus:= 0;
minus:= 0;
for i:=1 to length(s) do
begin
if s[i] = '+' then plus := plus + 1;
if s[i] = '-' then minus := minus + 1;
end;
writeln;
if plus > minus then for i:=1 to plus do
write('+')
else if plus < minus then for i:=1 to minus do
write('-')
else write('Кол-во знаков одинаковое!');
end.
2)
program fantscrin;
var y,x,b,e:real; i:integer;
begin
write('Введите число b:'); readln(b);
e:= 2.7;
x:= 0;
writeln;
writeln(' y | x ');
writeln('');
while x <= 10 do
begin
if x < 3 then
begin
y:= Exp(x * Ln(e)) + 1 / (x + 1);
writeln(y:6:5, ' | ', x:6:5)
end;
if x = 3 then
begin
y:= Sin(x) + sqrt(x);
writeln(y:6:5, ' | ', x:6:5);
end;
if x > 3 then
begin
y:= Cos(x) + Abs(b);
writeln(y:6:5, ' | ', x:6:5);
end;
x:= x + 0.5;
end;
end.
open System
let anyNumberSymbol = "?"
let replaceSymbolOnIndex (str:string) (number:int) (index:int) =
String.Format("{0}{1}{2}", str.Substring(0, index), number, str.Substring(index+1))
let rec getAllValues (valueStr:string) =
let index = valueStr.IndexOf(anyNumberSymbol)
if index > -1
then
let newStrings =
[0..9]
|> Seq.map (fun x -> replaceSymbolOnIndex valueStr x index)
newStrings |> Seq.collect (fun x -> getAllValues x)
else
[valueStr] |> List.toSeq
let getResults (numbers:string list) =
List.nth numbers 0
|> getAllValues
|> Seq.map (fun firstNumber ->
List.nth numbers 1
|> getAllValues
|> Seq.map (fun secondNumber ->
List.nth numbers 2
|> getAllValues
|> Seq.map (fun resultNumber ->
if Int32.Parse(firstNumber) + Int32.Parse(secondNumber) = Int32.Parse(resultNumber)
then [String.Format("{0} + {1} = {2}", firstNumber, secondNumber, resultNumber)]
else []
)
|> Seq.collect (fun x -> x)
)
|> Seq.collect (fun x -> x)
)
|> Seq.collect (fun x -> x)
|> Seq.toArray
[<EntryPoint>]
let main argv =
let inputString = System.Console.ReadLine()
let numbers = inputString.Split('+', '=') |> Array.map (fun x -> x.Trim())
if numbers.Length = 3
then
let results = getResults (numbers |> Array.toList)
if results.Length > 0
then Console.WriteLine(results |> Seq.fold (fun result x -> result + "\n" + x) "")
else Console.WriteLine("No results")
Console.ReadKey(true) |> ignore
0
else
1