Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4a81d5d

Browse files
feat: add csharp solution to lc problem: No.0009
1 parent b13b1d1 commit 4a81d5d

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

‎solution/0000-0099/0009.Palindrome Number/README.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,27 @@ var isPalindrome = function (x) {
210210
};
211211
```
212212

213+
#### C#
214+
215+
```cs
216+
public class Solution
217+
{
218+
public bool IsPalindrome(int x)
219+
{
220+
if (x < 0 || (x > 0 && x % 10 == 0))
221+
{
222+
return false;
223+
}
224+
int y = 0;
225+
for (; y < x; x /= 10)
226+
{
227+
y = y * 10 + x % 10;
228+
}
229+
return x == y || x == y / 10;
230+
}
231+
}
232+
```
233+
213234
#### PHP
214235

215236
```php

‎solution/0000-0099/0009.Palindrome Number/README_EN.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,27 @@ var isPalindrome = function (x) {
202202
};
203203
```
204204

205+
#### C#
206+
207+
```cs
208+
public class Solution
209+
{
210+
public bool IsPalindrome(int x)
211+
{
212+
if (x < 0 || (x > 0 && x % 10 == 0))
213+
{
214+
return false;
215+
}
216+
int y = 0;
217+
for (; y < x; x /= 10)
218+
{
219+
y = y * 10 + x % 10;
220+
}
221+
return x == y || x == y / 10;
222+
}
223+
}
224+
```
225+
205226
#### PHP
206227

207228
```php
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
public class Solution
2+
{
3+
public bool IsPalindrome(int x)
4+
{
5+
if (x < 0 || (x > 0 && x % 10 == 0))
6+
{
7+
return false;
8+
}
9+
int y = 0;
10+
for (; y < x; x /= 10)
11+
{
12+
y = y * 10 + x % 10;
13+
}
14+
return x == y || x == y / 10;
15+
}
16+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /