Технический форум

Технический форум (http://www.tehnari.ru/)
-   Помощь студентам (http://www.tehnari.ru/f41/)
-   -   Проблемы с блок-схемой (http://www.tehnari.ru/f41/t100170/)

АнастасияMADI 18.12.2014 23:13

Проблемы с блок-схемой
 
Проблемы с блок-схемой! Пожалуйста, помогите разобраться! Заранее очень благодарю!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace Podmnoczistva
{
class Program
{
static void Main(string[] args)
{
int N = 20;
bool fl = false;
int[] mas = new int[N];
Console.WriteLine("a)Sluchajnije chosla;");
Console.WriteLine("b)Ruchnoj vvod;");
Console.WriteLine("c)Vvod iz fajla;");
Console.Write("Vaberite variant: ");
string s = Console.ReadLine();
switch (s[0])
{
case 'a':
{
try
{
Random rand = new Random(21);
for (int i = 0; i < N; i++)
{
mas[i] = rand.Next(-10, 11);
Console.Write(mas[i].ToString() + " ");
}
Console.WriteLine();
}
catch (Exception exc)
{
Console.WriteLine("OSHIBKA!!! " + exc.Message);
};
fl = true;
} break;
case 'b':
{
try
{
int t = 0;
while (t < 20)
{
Console.Write("Vvedite chislo: ");
int z = Convert.ToInt32(Console.ReadLine());
if (z >= -10 && z <= 10)
{
mas[t] = z;
t++;
}
else
{
Console.Write("Ne vhodit chislo v interval ot -10 do 10!");
}
}
}
catch (Exception exc)
{
Console.WriteLine("OSHIBKA!!! " + exc.Message);
};
fl = true;
} break;
case 'c':
{
try
{
Console.Write("Vvedite polnij address fajla: ");
string path = Console.ReadLine();
StreamReader file = new StreamReader(path);
string temp = file.ReadLine();
string []lll = temp.Split(';');
if (lll.Count() == 20)
{
for (int i = 0; i < 20; i++)
{
mas[i] = Convert.ToInt32(lll[i]);
Console.Write(mas[i].ToString() + " ");
}
Console.WriteLine();
}
else
Console.WriteLine("OSHIBKA!!!");
}
catch (Exception exc)
{
Console.WriteLine("OSHIBKA!!! " + exc.Message);
};
fl = true;
} break;
}
if (fl)
{
List<string> list = new List<string>();
for (int i = 0; i < N; i++)
{
if (mas[i] < 10)
{
string str = "";
list.Add(i.ToString() + ":" + mas[i].ToString());
//int sum = mas[i];
for (int j = i + 1; j < N; j++)
{
int sum = mas[i];
str += i.ToString() + ":" + mas[i].ToString() + " ";
for (int k = j; k < N; k++)
{
if (sum + mas[k] < 10)
{
sum += mas[k];
str += k.ToString() + ":" + mas[k].ToString() + " ";
}
}
//str += "\n";
if (list.IndexOf(str) < 0)
list.Add(str);
}
}
}
for (int i = 0; i < list.Count; i++)
{
Console.WriteLine((i + 1).ToString() + ") " + list[i]);
Console.WriteLine();
}
};
Console.ReadKey();
Console.ReadKey();
}
}
}

Замечание:
Уважаемая Анастасия, убедительно прошу соблюдать Правила нашего форума, которые, в частности, запрещают:
1. именование тем в стиле "Помогите!", "Help!!!", "Прошу помощи!" и т.п.
2. кросспостинг (размещение дубликатов тем в разных разделах).

Модератор


Часовой пояс GMT +4, время: 03:25.

Powered by vBulletin® Version 4.5.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.