Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace Find_Largest_Three_Values_2
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int firstNum = int.MinValue;
- int secondNum = int.MinValue;
- int thirdNum = int.MinValue;
- for (int i = 0; i < n; i++)
- {
- int currentNum = int.Parse(Console.ReadLine());
- if (currentNum > firstNum)
- {
- thirdNum = secondNum;
- secondNum = firstNum;
- firstNum = currentNum;
- }
- else if (currentNum > secondNum)
- {
- thirdNum = secondNum;
- secondNum = currentNum;
- }
- else if (currentNum > thirdNum)
- {
- thirdNum = currentNum;
- }
- }
- Console.WriteLine($"{firstNum}, {secondNum} and {thirdNum}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment