М
Молодежь
К
Компьютеры-и-электроника
Д
Дом-и-сад
С
Стиль-и-уход-за-собой
П
Праздники-и-традиции
Т
Транспорт
П
Путешествия
С
Семейная-жизнь
Ф
Философия-и-религия
Б
Без категории
М
Мир-работы
Х
Хобби-и-рукоделие
И
Искусство-и-развлечения
В
Взаимоотношения
З
Здоровье
К
Кулинария-и-гостеприимство
Ф
Финансы-и-бизнес
П
Питомцы-и-животные
О
Образование
О
Образование-и-коммуникации
zagariyolga068
zagariyolga068
18.06.2020 14:53 •  Информатика

Написать в паскале. задан массив значений аргумента х=(1.2; 1.8; -4; -1.5; -0.6; 0.2; 0.5; 14; 26; -8.4). определить количество четных чисел в массиве х и их среднее арифметическое значение . х-вводим с клавиатуры.

👇
Ответ:
AlexMason03
AlexMason03
18.06.2020
uses Crt;
const n=10;
Type Mas=array [1..n] of real;
var  X: Mas;
     i, Col: integer;
     Sum, Sred: real;
begin
ClrScr;
for i:=1 to n do
   begin
      Write (' X[',i,'] ='); ReadLn(X[i]);
      if  frac (X[i])=0 and (X[i]  mod 2 =0)  then
      begin
            Col:=Col+1;
            Sum:=Sum+X[i];
      end;
    end;
    WriteLn;
    Sred:=Sum/Col;
   WriteLn (' Количество четных = ', Col);
   Writeln (' Их среднее число = ', Sred:6:3);
ReadLn;
end.
4,7(71 оценок)
Открыть все ответы
Ответ:
Leska7
Leska7
18.06.2020

Для В допустим, что слева направо.

class BirthDate{

private int day;

private int month;

private int year;

 

BirthDate(int day, int month, int year){

 this.day = day;

 this.month = month;

 this.year = year;

}

public int getDay() {

 return day;

}

public void setDay(int day) {

 this.day = day;

}

public int getMonth() {

 return month;

}

public void setMonth(int month) {

 this.month = month;

}

public int getYear() {

 return year;

}

public void setYear(int year) {

 this.year = year;

}

 

public boolean isOlder(BirthDate bd) {

 return this.year >= bd.getYear() && this.month >= bd.getMonth()  && this.day > bd.getDay();

}

}

class Human{

private BirthDate birthDate;

private String name;

 

Human(String name, BirthDate birthDate){

 this.birthDate = birthDate;

 this.name = name;

}

 

public BirthDate getBirthDate(){

 return this.birthDate;

}

 

public void setBirthDate(BirthDate bd) {

 this.birthDate = bd;

}

 

public String getName(){

 return this.name;

}

 

public void setName(String name) {

 this.name = name;

}

}

public class Task {

 

private static boolean isSumNumberTwoDecimal(int number) {

 int sum = 0;

 while(true) {

  sum += number % 10;

  number /= 10;

  if(number < 1) {

   break;

  }

 }

 return sum < 100;

}

 

private static String whichSeason(int month) {

 if(month >= 1 && month <= 2 && month == 12) {

  return "Winter";

 } else if(month >= 3 && month <= 5) {

  return "Spring";

 } else if(month >= 6 && month <= 8) {

  return "Summer";

 } else if(month >= 9 && month <= 11){

  return "Autumn";

 } else {

  return "There's no such month";

 }

}

 

private static boolean isSameFirstAndSecond(int number, int numeral){

 String sNbr = String.valueOf(number).substring(0, 2);

 return Integer.valueOf(sNbr) == numeral;

}

 

private static boolean isOlder(Human h1, Human h2) {

 return h1.getBirthDate().isOlder(h2.getBirthDate());

}

 

public static void main(String[] args) {

 int number = 2939393;

 System.out.println(isSumNumberTwoDecimal(number));

 //Month and date has correct values

 int month = 10;

 Human vasya = new Human("Vasya", new BirthDate(1, month, 1990));

 Human natalia = new Human("Natalia", new BirthDate(1, month, 1989));

 System.out.println(isOlder(vasya, natalia));

 System.out.println(whichSeason(month));

 System.out.println(isSameFirstAndSecond(number, 29));

}

}

4,8(45 оценок)
Ответ:
Chelovekkkkkkk1701
Chelovekkkkkkk1701
18.06.2020
Using System;using System.Collections.Generic;using System.Linq;using System.Text.RegularExpressions;
namespace Rextester{    public class Program    {        public static void Main(string[] args)        {
                       int distance = 10;             // дистанция в километрах            int loss_of_fuel = 5;         // расход литров бензина на километр            int available_fuel = 100;  // литров бензина в баке                                   if (available_fuel/loss_of_fuel < distance){                    Console.WriteLine("Не хватит");            }else{                    Console.WriteLine("Хватит");            }                    }    }}
4,7(36 оценок)
Это интересно:
Новые ответы от MOGZ: Информатика
logo
Вход Регистрация
Что ты хочешь узнать?
Спроси Mozg
Открыть лучший ответ