File tree 3 files changed +58
-0
lines changed
solution/0000-0099/0009.Palindrome Number
3 files changed +58
-0
lines changed Original file line number Diff line number Diff line change @@ -210,6 +210,27 @@ var isPalindrome = function (x) {
210
210
};
211
211
```
212
212
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
+
213
234
#### PHP
214
235
215
236
``` php
Original file line number Diff line number Diff line change @@ -202,6 +202,27 @@ var isPalindrome = function (x) {
202
202
};
203
203
```
204
204
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
+
205
226
#### PHP
206
227
207
228
``` php
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments