Advertisement
Adijata

Prva vježba 2013 RPR petii zadatak

Oct 9th, 2014
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.91 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication7
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.            
  14.             Console.WriteLine("Unesite riječ: ");
  15.             string palindrom = Console.ReadLine();
  16.             bool nesto = Program.dalijepal(palindrom);
  17.             Console.WriteLine("Riječ je palindrom: {0}", nesto);
  18.  
  19.  
  20.             Console.ReadLine();
  21.         }
  22.  
  23.      public static bool dalijepal(string riječ)
  24.     {
  25.          bool palindrom=true;
  26.         for(int i=1; i<riječ.Length; i++)
  27.          {
  28.              if (riječ[i] != riječ[riječ.Length - i-1] && riječ[i] != riječ[riječ.Length - i-1] + 'A')
  29.              {
  30.                  palindrom=false;
  31.                  break;
  32.              }
  33.          }
  34.         return palindrom;
  35.     }
  36.  
  37.     }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement