New Test

download New Test

If you can't read please download the document

description

asd

Transcript of New Test

using System;using System.Collections.Generic;using System.Linq;namespace MyClass{ class Program { static void Main(string[] args) { // maxnum(12354); string str = Console.ReadLine(); string[] arr = str.Split(' '); int sum=0; int min = 0; foreach (var item in arr) { sum+=maxnum(int.Parse(item));min+=minnum(int.Parse(item)); } Console.WriteLine(sum+" "+min); } public static int maxnum(int num) { List list = new List(); while (num > 0) { list.Add(num % 10); num = num / 10; } int result = 0; int number = list.Count(); for (int j = number; j > 0; j--) { if (list[j - 1] == 5) { result = 6 + result * 10; } else result = list[j - 1] + result * 10; } return result; } public static int minnum(int num) { List list = new List(); while (num > 0) { list.Add(num % 10); num = num / 10; } int result = 0; int number = list.Count(); for (int j = number; j > 0; j--) { if (list[j - 1] == 6) { result = 5 + result * 10; } else result = list[j - 1] + result * 10; } return result; } }}