В массиве из 10 положительных и отрицательных элементов все четные положительные числа заменить «2», а остальные оставить без изменения. Напечатать на экране начальный массив A и конечный массив B.
Ответы на вопрос:
//поскольку вы не указали структуру файла и язык программирования, то подберу их сам.
//яп: 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.;
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();
}
}
}
}
Популярно: Информатика
-
AnyaManankina04.05.2021 20:30
-
pervushin75226.03.2023 06:36
-
Gudimnik116.09.2021 12:55
-
arlashmanov02.10.2022 12:05
-
Анастасия041104.12.2020 04:40
-
mregor328.05.2021 08:41
-
nevmer01.05.2021 20:52
-
kefir926.01.2020 08:18
-
Сонька76630.04.2021 04:41
-
morfinn26.04.2021 15:22