Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
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
R
Coding Exercise
multiplicação
linq
Ki
Robot_Testing
3
Why do my posts keep getting deleted?
Examples of JS-Like higher-order functions in C#
aa