मैं कोई तरीका होना चाहिएकंसोल चार्ट ड्राइंग
Dictionary<int, int> chartList = new Dictionary<int, int>()
{
{50,31}, // x = 50, y = 31
{71,87},
{25,66},
{94,15},
{33,94}
};
DrawChart(chartList);
की तरह एक सांत्वना आवेदन में एक Dictionary<int,int>
आकर्षित करने के लिए
की तरह कुछ में परिणाम चाहिए मैं इस आए हैं अब तक, लेकिन मैं कर रहा हूँ IsHit
विधि पर फंस गया, जो निर्धारित करता है कि मौजूदा निर्देशांक पर एक बिंदु निर्धारित किया जाना चाहिए या नहीं। क्या कोई इस बिंदु पर मेरी मदद कर सकता है? यह हमेशा सच रहता है।
public static void DrawChart(Dictionary<int, int> dict)
{
int consoleWidth = 78;
int consoleHeight = 20;
Console.WriteLine(dict.Max(x => x.Key).ToString());
Func<int, int, bool> IsHit = (hx, hy) => dict.Any(dct => dct.Key/dict.Max(x => x.Key) == hx/dict.Max(x => x.Key) && dct.Value/dict.Max(x => x.Value) == hy/dict.Max(x => x.Value));
for (int i = 0; i < consoleHeight; i++)
{
Console.Write(i == 0 ? '┌' : '│');
for (int j = 0; j < consoleWidth; j++)
{
int actualheight = i * 2;
if (IsHit(j, actualheight) && IsHit(j, actualheight + 1))
{
Console.ForegroundColor = ConsoleColor.Red;
Console.BackgroundColor = ConsoleColor.Black;
Console.Write('█');
}
else if (IsHit(j, actualheight))
{
Console.ForegroundColor = ConsoleColor.Red;
Console.BackgroundColor = ConsoleColor.Black;
Console.Write('▀');
}
else if (IsHit(j, actualheight + 1))
{
Console.ForegroundColor = ConsoleColor.Black;
Console.BackgroundColor = ConsoleColor.Red;
Console.Write('▀');
}
}
Console.ResetColor();
Console.WriteLine();
}
Console.WriteLine('└' + new string('─', (consoleWidth/2) - 1) + '┴' + new string('─', (consoleWidth/2) - 1) + '┘');
Console.Write((dict.Min(x => x.Key) + "/" + dict.Min(x => x.Value)).PadRight(consoleWidth/3));
Console.Write((dict.Max(x => x.Value)/2).ToString().PadLeft(consoleWidth/3/2).PadRight(consoleWidth/3));
Console.WriteLine(dict.Max(x => x.Value).ToString().PadLeft(consoleWidth/3));
}
फ़ंक्शन सेटपॉइंट (पंक्ति, कॉल, चार, रंग) क्यों नहीं लिखें? आप आसानी से [कर्सर को किसी भी समन्वय में सेट कर सकते हैं] (https://msdn.microsoft.com/en-us/library/system.console.setcursorposition (v = vs.110) .aspx) सभी के बाद .. – TaW
क्या ' आप बस शब्दकोश पर लूप और केवल हिट पॉइंट आकर्षित करते हैं ..? – TaW
निश्चित रूप से मैं सिर्फ http://stackoverflow.com/a/33604540/1315444 – fubo