Решение такое (для x=1,2,3,4,5,6,7,8,9,10. ):
var
x, y: real;
begin
writeln('*********************');
writeln('* X * Y *');
writeln('*********************');
for x := 1 to 10 do
begin
if x>=0 then y:=5*x else y:=4*x+2;
writeln('* 'x,' * ',y,' *');
end;
writeln('*********************');
end.
Но лучше сделать ввод значений х с клавиатуры:
var
y: real; i:integer;
mas: array[1..10] of real;
begin
for i := 1 to 10 do
begin
write ('Введите ',i,'-е значение ');
readln (mas[i]);
end;
writeln('*********************');
writeln('* X * Y *');
writeln('*********************');
for i := 1 to 10 do
begin
if mas[i]>=0 then y:=5*mas[i] else y:=4*mas[i]+2;
writeln('* ',mas[i],' * ',y,' *');
end;
writeln('*********************');
end.
//Поскольку вы не указали структуру файла и язык программирования, то подберу их сам.
//ЯП: C#
//Структура: рост/имя/вес/страна проживания
Код:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace Prog
{
class Program
{
static void Main(string[] args)
{
string location = "C://Test//Persons.txt";
try
{
int size = File.ReadLines(location).Count();
if (size > 0)
{
List<string> person = new List<string>();
string[] tallestPerson = new string[4];
int maxHeight = -1;
int height = 0;
int index = 0;
StreamReader PersonsReader = new StreamReader(location, Encoding.Default);
for (int i = 0; i < size; i++)
{
person.Add(PersonsReader.ReadLine());
height = Convert.ToInt32(person[i].Remove(person[i].IndexOf("/")));
if (height > maxHeight)
{
maxHeight = height;
index = i;
}
}
string tmp = person[index];
int paramIndex = 0;
for (int j = 0; j < tmp.Length; j++)
{
if (tmp[j] != '/')
tallestPerson[paramIndex] += tmp[j];
else
paramIndex++;
}
Console.WriteLine("Самый высокий человек: " + tallestPerson[1]);
Console.WriteLine("Рост: " + tallestPerson[0] + " см");
Console.WriteLine("Вес: " + tallestPerson[2] + " кг");
Console.WriteLine("Страна проживания: " + tallestPerson[3]);
}
else
{
Console.WriteLine("Файл пустой!");
}
}
catch (Exception)
{
Console.WriteLine("Ошибка! Файл не нейден, либо нарушена его структура!");
}
finally
{
Console.ReadKey();
}
}
}
}
это В
Объяснение: