18.12.2014, 23:13 | #1 (permalink) | ||
Новичок
Регистрация: 18.12.2014
Сообщений: 1
Сказал(а) спасибо: 0
Поблагодарили 0 раз(а) в 0 сообщениях
Репутация: 10
|
Проблемы с блок-схемой
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(); } } }
|
||
18.12.2014, 23:13 | |
Helpmaster
Member
Регистрация: 08.03.2016
Сообщений: 0
|
Не стоит напрасно тратить время, лучше посмотрите аналогичные темы Проблемы со схемой Помощь с блок-схемой Помогите с блок схемой Проблемы со схемой Проблемы со схемой Помогите, пожалуйста, с блок-схемой |
Ads | |
Member
Регистрация: 31.10.2006
Сообщений: 40200
Записей в дневнике: 0
Сказал(а) спасибо: 0
Поблагодарили 0 раз(а) в 0 сообщениях
Репутация: 55070
|
|
|