Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
Palindrome 1
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static bool IsOdd(int value) { return value % 2 != 0; } public static void Main(string[] args) { //Your code goes here bool ispol = true; string num = "12321"; int num_leng = num.Length; int diff; if(IsOdd(num_leng) == true){ //Odd diff = (num_leng - 1)/2; }else{ //Even diff = (num_leng)/2; } for(int i=0;i<diff;i++){ if(num[i] != num[num_leng-(i+1)]){ ispol = false; break; } } Console.WriteLine("Palindrome: " + ispol); } } }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
hay
custom Queue Implementation
rd
Pentagon`s area
Event test
project euler 13, C#
Encrption & Decryption C#
Generic operator test
Kopia
Math Prime Numbers
Please log in to post a comment.