Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication13
- {
- class Program
- {
- static int Vstup(ref int cislo)
- {
- int pruchod = 0;
- Console.WriteLine("Zadejte cislo (0=konec)");
- do
- {
- if (pruchod > 0) Console.WriteLine("Nebylo zadano cele cislo.");
- pruchod++;
- } while (!(int.TryParse(Console.ReadLine(), out cislo)));
- return cislo;
- }
- static void Zadat()
- {
- int cislo = 0;
- int pocet = 1;
- int max1 = 0, max2 = 0;
- do
- {
- Vstup(ref cislo);
- if (pocet == 1)
- {
- max1 = cislo;
- max2 = 0;
- }
- if (cislo != 0)
- {
- if (cislo > max1)
- {
- max2 = max1;
- max1 = cislo;
- }
- else if (cislo > max2 && cislo != max1)
- {
- max2 = cislo;
- }
- }
- pocet++;
- } while (cislo != 0);
- if (pocet < 2) Console.WriteLine("Zadejte alespon 2 cisla");
- Console.WriteLine("Druhe nejvyssi cislo v rade je " + max2);
- }
- static void Main(string[] args)
- {
- char volba = '9';
- do
- {
- Console.Clear();
- if (volba == '1') Zadat();
- Console.WriteLine("1..Zadat ciselnou radu\n-----------------\n9..Konec");
- volba = Console.ReadKey().KeyChar;
- } while (volba != '9');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement