//Example: n=2071. The number big number second is 2
Source code:
class Program{
static void Main (){
int
n;
int[]
arr = new int[4];
do
{
Console.Write("Input n has 4 digits: ");
n = int.Parse(Console.ReadLine());
} while
(n < 1000 || n > 9999);
for
(int i = 0; i < 4; i++){
arr[i] = n % 10;
n = n / 10;
}
for
(int i = 0; i < 3; i++)
for
(int j = i+1; j < 4;j++)
if
(arr[i] => arr[j]){
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
Console.WriteLine("The second big number is: {0}",
arr[2]);
Console.ReadLine();
}
}
No comments:
Post a Comment