using System; using CodEx; namespace JedenProtiStu { class Jeden_proti_stu { static Pole zasobnik; static void Main(string[] args) { int souperu = 100; int kol = Reader.Console().Int(); int penez = 100000; int suma = 0; zasobnik = new Pole(souperu, kol); // zasobnik.Vypis(); // for (int i = 1; i <= 10; i++) // { cifra(souperu, penez, suma, kol); Console.WriteLine(sup); foreach (int cislo in buffer2) { Console.Write("{0} ", cislo); } // } // Console.WriteLine("--konec--"); // Console.ReadLine(); //BACHA! MUSI SE PAK ZRUSIT } public static int sup = 0; class Pole { int vyska; int sirka; public int[,] zasobnik; public void Vypis() { for (int i = 0; i <= vyska - 1; i++) for (int j = 0; j <= sirka - 1; j++) { if(j 0) { if (souperu > 0) { for (int zbylo = 0; zbylo <= souperu; zbylo++) { suma = suma + penez * (souperu - zbylo) / souperu; //kontrola //if(zasobnik[souperu-1,kol-1] Jeden_proti_stu.buffer.Add(souperu - zbylo); cifra(zbylo, penez, suma, kol - 1); suma = suma - penez * (souperu - zbylo) / souperu; //ODEBRAT POSLEDNI PRVEK Jeden_proti_stu.buffer.RemoveAt(Jeden_proti_stu.buffer.Count-1); } } else { } } else { //budovat string s cisly..} if (suma > Jeden_proti_stu.sup) { Jeden_proti_stu.buffer2.Clear(); foreach (int cislo in buffer) { Jeden_proti_stu.buffer2.Add(cislo); } Jeden_proti_stu.sup = suma; /*int[] temp = new int[buffer.Count]; foreach (string prvecek in buffer) { temp[j] = prvecek; j++; } temp = buffer; buffer.Clear(); jeden_proti_stu.vysledek = temp;*/ } } } } } namespace CodEx { /// /// Class Reader provides user friendly adaptor for reading text files and text console input. /// If offers simple methods to read numbers, chars and string tokens. /// public class Reader : System.IDisposable { #region Inicialization and destruction /// Initializes reader object and assigns given stream reader. /// Stream reader object used as input. private Reader(System.IO.TextReader s) { stream = s; buf = new char[BUFLEN]; index = 0; len = 0; } /// Opens given file and assigns it to created Reader object. /// Name of the file to be opened. public Reader(string fname) : this(new System.IO.StreamReader(fname, System.Text.Encoding.ASCII, false)) { } /// Static singleton value that keeps console Reader object. private static Reader console = null; /// Method providing access to universal console Reader object. public static Reader Console() { if (console == null) console = new Reader(System.Console.In); return console; } /// Internal disposer of reader stream. private void FreeStream() { if (stream != null) { ((System.IDisposable)stream).Dispose(); stream = null; } } /// /// Method that closes the reader and underlying stream object. /// It is recomended to use this method rather than wait for fializer. /// public void Dispose() { FreeStream(); System.GC.SuppressFinalize(this); } /// Finalizer is not usually used. But if it is, it does the same as Dispose method. ~Reader() { FreeStream(); } #endregion #region Public core methods /// Reads one character from input. /// Output variable where the character is stored. /// True if the reading was successfull, false otherwise. public bool Char(out char c) { if (!Update()) { c = '\0'; return false; } c = buf[index++]; return true; } /// Reads integer number from text file. /// Output variable where the integer is stored. /// True if the reading was successfull, false otherwise. public bool Int(out int i) { if (!SkipSpaces()) { i = 0; return false; } i = 0; int sign = 1; if (buf[index] == '+') index++; else if (buf[index] == '-') { sign = -1; index++; } if (!Update() || !System.Char.IsDigit(buf[index])) throw new System.IO.IOException("No digit found when reading number."); while (Update() && System.Char.IsDigit(buf[index])) { i = i * 10 + sign * ((int)buf[index++] - (int)'0'); } return true; } /// Reads real number from text file. /// Output variable where the double is stored. /// True if the reading was successfull, false otherwise. public bool Double(out double d) { { int i; if (!Int(out i)) { d = 0; return false; } d = i; } if (Update() && buf[index] == '.') { index++; double frac = 1.0; while (Update() && System.Char.IsDigit(buf[index])) { frac /= 10.0; d += frac * ((int)buf[index++] - (int)'0'); } } if (Update() && System.Char.ToLower(buf[index]) == 'e') { index++; d *= System.Math.Pow(10, Int()); // If no exponent can be parsed -> IOException. } return true; } /// Reads one string token from input. Token does not contain any blank spaces. /// String object containing the token or null if reading was not successfull. public string Word() { if (!SkipSpaces()) return null; int start = index; while (index < len && !System.Char.IsWhiteSpace(buf[index])) index++; if (index < len) return new string(buf, start, index - start); System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(buf, start, index - start); while (index == len && Update()) { while (index < len && !System.Char.IsWhiteSpace(buf[index])) index++; sb.Append(buf, 0, index); } return sb.ToString(); } /// Reads rest of the line from input. /// String object containing the line or null if EOF was met. public string Line() { if (!Update()) return null; int start = index; while (index < len && buf[index] != '\n') index++; if (index < len) return new string(buf, start, index++ - start); System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(buf, start, index - start); while (index == len && Update()) { while (index < len && buf[index] != '\n') index++; sb.Append(buf, 0, index); } if (index < len) index++; return sb.ToString(); } #endregion #region Convenience methods /// Checks if the input stream ended. /// True if there are no more characters on the input. public bool EOF() { return !Update(); } /// Skips whitespace characters and then checks for EOF. /// True if there are only blank characters left in the input. public bool SeekEOF() { return !SkipSpaces(); } /// Alias for Dispose method that closes underlying stream. public void Close() { Dispose(); } /// Reads one character from input. Throws IOException on error. /// Character that was read from the input. public char Char() { char ret; if (!Char(out ret)) throw new System.IO.IOException("Reading after EOF."); return ret; } /// Reads integer number from input. Throws IOException on error. /// Integer that was read from the input. public int Int() { int ret; if (!Int(out ret)) throw new System.IO.IOException("Reading after EOF."); return ret; } /// Reads real number from input. Throws IOException on error. /// Double that was read from the input. public double Double() { double ret; if (!Double(out ret)) throw new System.IO.IOException("Reading after EOF."); return ret; } #endregion #region Fields /// Underlying stram object. It is not null while the stream is opened. private System.IO.TextReader stream; /// Read but unprocessed data. Null after EOF. private char[] buf; private const int BUFLEN = 16384; /// Actual index to the buf. private int index; /// Length of buf. Len == -1 means EOF. private int len; #endregion #region Private methods /// Ensures that index is lesser than len whenever possible. /// False on EOF, true otherwise. private bool Update() { // if (stream == null || len == -1) return false; if (index < len) return true; index = 0; if ((len = stream.Read(buf, 0, BUFLEN)) == 0) { len = -1; buf = null; return false; } return true; } /// Skip whitespaces. /// Returns false when EOF is found while skipping, true otherwise. private bool SkipSpaces() { while (Update()) { while (index < len && System.Char.IsWhiteSpace(buf[index])) index++; if (index < len) return true; } return false; } #endregion } }