Есть ответ 👍

В массиве из 10 положительных и отрицательных элементов все четные положительные числа заменить «2», а остальные оставить без изменения. Напечатать на экране начальный массив A и конечный массив B.

184
403
Посмотреть ответы 1

Ответы на вопрос:


//поскольку вы не указали структуру файла и язык программирования, то подберу их сам.

//яп: 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();

}

}

}

}

Популярно: Информатика