Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
can anyone help me to convert this pseudo to c#.

program projectx  
String x;
  Boolean f; 
 integer a,z,g; 
 x = readinput; 
 g = length of x;  
z = g minus one; 
 a = zero 
 if g = 1 then 
f = 1
  else  
 f = 1;   
while f=1 and a less than z 

while character at a of x is one of 

[whitespace,comma,semicolon, exclamation_mark, question_mark, or full stop] a++; 

while character at z of x is one of 

[whitespace,comma,semicolon, exclamation_mark, question_mark, or full stop] z--;

 if the toUpperCase of character at a of x is identical to the toUpperCase of character at z of x then a++ and z--;  
  
else f=0; 

if f=0 then print out appropriate message 
 
else 
print out other appropriate message


What I have tried:

C#
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string x;

            bool f;

            int a, z, g;

            x = Console.ReadLine();
            g = x.Length;
            z = g - 1;
            a = 0;

            if (g == 1)
                f = true;
            else
            {
                f = true;
                while (f && a < z)
                {
                    while (x,a = (" "  "," ";" "!"  "?"  "."))
                    a++;
                }

                {
                    while (x[z] = (" "  "," "," "!"  "?"  "."))
                    z--;
                }

                if toUpper(x[a]) == toupper(x[z]))
                    a++;
                z--;
            }
            { 
               else
            {
                f = false;
            }

            {
                if (!f)
                    Console.ReadLine  "Palindrome";
                else
                    Console.ReadLine  "NotPalindrome";
                
            }


        }
    }
    }
Posted
Updated 1-May-18 8:39am
v2
Comments
Patrice T 1-May-18 14:40pm    
What is the problem in your code ?
Member 13736730 1-May-18 14:42pm    
The code was in c++ and I was converting it into c# and I’m not good at c# so some code have c++ characteristics
[no name] 1-May-18 14:57pm    
What is the specific Problem you face? Do not expect that someone here is keen on to debug your code ;)
BillWoodruff 1-May-18 16:19pm    
I suggest you write an outline of the steps to determine if a string is a palindrome, and then implement that in C#. You can filter the string of all punctuation easily, then work with it.

string punc = $"!@&(),:;-";

string nopunc = new string(punc.Where(c => !char.IsPunctuation(c)).ToArray());
#realJSOP 2-May-18 10:24am    
I'd like to see his instructor's reaction when he hands that in. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900