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;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int Min_Positive, Max_Negative = 0, Current_Num, Numbers=0;
- do
- {
- Console.Write("Enter The "+ (Numbers+1)+" Number: ");
- Current_Num=int.Parse(Console.ReadLine());
- if(Current_Num<0 && Current_Num<Max_Negative) //IF NEGATIVE AND CURRENTLY THE BIGGEST NEGATIVE
- Max_Negative=Current_Num;
- Numbers++;
- }
- while(Current_Num < 0 && Numbers < 10 );
- if(Numbers == 10)
- {
- Min_Positive=0; //THERE WERE NO POSITIVE NUMBERS ENTERED
- Console.WriteLine("There were no positive numbers in your input");
- Console.WriteLine("Maximum negative number is: "+ Max_Negative);
- }
- else
- {
- Min_Positive=Current_Num;
- for (int i = Numbers; i < 10; i++) //CONTINUE ASKING FOR INPUT
- {
- Console.Write("Enter The " + (i + 1) + " Number: ");
- Current_Num=int.Parse(Console.ReadLine());
- if(Current_Num > 0 && Current_Num < Min_Positive) //IF POSITIVE AND IT IS THE CURRENT MINIMUM
- Min_Positive = Current_Num;
- if (Current_Num < 0 && Current_Num > Max_Negative) ////IF NEGATIVE AND IT IS THE MAXIMUM NEGATIVE
- Max_Negative = Current_Num;
- }
- Console.WriteLine("Minimum positive number: " + Min_Positive);
- if(Max_Negative==0)
- Console.WriteLine("There were no negative numbers in your input");
- else
- Console.WriteLine("Maximum negative number is: " + Max_Negative);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment