diff --git a/problems/1317-convert-integer-to-the-sum-of-two-no-zero-integers/csharp/Program.cs b/problems/1317-convert-integer-to-the-sum-of-two-no-zero-integers/csharp/Program.cs new file mode 100644 index 0000000..e5087b9 --- /dev/null +++ b/problems/1317-convert-integer-to-the-sum-of-two-no-zero-integers/csharp/Program.cs @@ -0,0 +1,52 @@ +// LeetCode 1317: Convert Integer To The Sum Of Two No Zero Integers +// 難度: Easy +// 日期: 2025-09-08 + +using System; +using System.Collections.Generic; +using System.Linq; + +public class Solution +{ + public int[] GetNoZeroIntegers(int n) + { + for (var i = 1; i < n; i++) + { + if (CheckIntegersWithNoZero(i) && CheckIntegersWithNoZero(n - i)) + { + return new int[]{i, n - i}; + } + } + return new int[]{}; + } + + private bool CheckIntegersWithNoZero(int n) + { + while (n > 0) + { + if (n % 10 == 0) + { + return false; + } + n /= 10; + } + return true; + } +} + +public class Program { + public static void Main() { + var Solution = new Solution(); + TestCase1(Solution); + // TestCase2(); + } + + static void TestCase1(Solution Solution) { + // Input: + var input = 1010; + // Expected: [11, 999] + int[] result = Solution.GetNoZeroIntegers(input); + // Actual: + Console.WriteLine($"Test 1: {result[0]}, {result[1]}"); + } +} diff --git a/problems/1317-convert-integer-to-the-sum-of-two-no-zero-integers/csharp/csharp.csproj b/problems/1317-convert-integer-to-the-sum-of-two-no-zero-integers/csharp/csharp.csproj new file mode 100644 index 0000000..2150e37 --- /dev/null +++ b/problems/1317-convert-integer-to-the-sum-of-two-no-zero-integers/csharp/csharp.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + +