Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
1
Добавлен:
01.12.2023
Размер:
1.27 Mб
Скачать

11

Графический способ записи алгоритма линейной программы В представлен на рисунке 2.4.

Рисунок 2.4 – Блок схема алгоритма D

12

Графический способ записи алгоритма линейной программы В представлен на рисунке 2.5.

Рисунок 2.5 – Блок схема алгоритма Е

Графический способ записи алгоритма линейной программы В представлен на рисунке 2.6.

13

Рисунок 2.6 – Блок схема алгоритма F

14

2.3 Листинг исходного кода программ

Листинг программы А представлен ниже.

using System;

namespace _1000_7

{

class Program

{

static void Main(string[] args)

{

int a = Convert.ToInt32(Console.ReadLine()); int b = Convert.ToInt32(Console.ReadLine()); int c = Convert.ToInt32(Console.ReadLine()); Console.WriteLine((a*b*c)*0.21);

}

}

}

Листинг программы B представлен ниже.

namespace _1000_7

15

{

class Program

{

static void Main(string[] args)

{

int a = Convert.ToInt32(Console.ReadLine()); int b = Convert.ToInt32(Console.ReadLine()); int c = Convert.ToInt32(Console.ReadLine()); int max = -100000;

if (a>max) max=a; if (b>max) max=b; if (c>max) max=c;

Console.WriteLine(max);

}

}

}

Листинг программы C представлен ниже.

using System;

16

namespace _1000_7

{

class Program

{

static void Main(string[] args)

{

int[] x = new int[10];

Random rnd = new Random(); int k = 0;

int c = 0;

for (int i = 0; i < 10; i++)

{

x[i] = rnd.Next(0,10);

}

for (int i = 0; i < 10; i++)

{

if (x[i]%x[0]==0)

{

k+=1;

}

}

for (int i = 0; i < 10; i++)

17

{

if (x[i]%x[9]==0)

{

c+=1;

}

}

if (c>k)

Console.WriteLine("Которые делятся на последний");

else

Console.WriteLine("Которые делятся на первый");

}

}

}

Листинг программы D представлен ниже.

using System; namespace _1000_7

{

class Program

{

static void Main(string[] args)

{

int a = Convert.ToInt32(Console.ReadLine()); int b = a;

18

int c = 0; int d =0; int e =0; while (a>0)

{

e = a%10; a = a/10; c+=1;

}

while (b>0)

{

d+= (b%10)*((c-1)*10); b=b/10;

}

d+=e;

Console.WriteLine(d);

}

}

}

Листинг программы E представлен ниже.

using System; namespace _1000_7

{

class Program

{

static void Main(string[] args)

19

{

int a = Convert.ToInt32(Console.ReadLine()); int b = Convert.ToInt32(Console.ReadLine()); int s = 0;

if (a<b)

{

while (a<=b)

{

s+=a;

a+=1;

}

}

else

{

while (b<=a)

{

s+=b;

b+=1;

}

}

Console.WriteLine(s);

}

}

}

Листинг программы F представлен ниже.

20

using System; namespace _1000_7

{

class Program

{

static void Main(string[] args)

{

int[] mas = new int[100]; int i = 0;

int s = 0; string test; int count = 0; do

{

test = Console.ReadLine(); if (test == "end")

break;

mas[i] = Convert.ToInt32(test); ++i;

++count;

}

while (true);

for (int j = 0; j < 100; j++)

{

if (mas[j]%2!=0) s+=mas[j];

else

break;

}

Console.WriteLine(s);

}

}

}

Соседние файлы в папке Ознакомительная практика