• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 177
  • Last Modified:

c /c++ nested if

hi i have the following code in vb i need to convert to c/c++ , can some assist, i have  spent almost 6 hrs trying to convert
If position_six_A <> "11" Then
            position_six = position_six + 1
            ElseIf position_six_A = "11" Then
            position_six = 0
        Else
            If position_five_A <> "E" Then
                position_five = position_five - 1
                position_six = position_six + 1
                ElseIf position_five_A = "E" Then
                position_five = 32
            Else
                If position_four_A <> "11" Then
                    position_four = position_four + 1
                    position_five = position_five - 1
                    position_six = position_six + 1
                    ElseIf position_four_A = "11" Then
                    position_four = 0
                Else
                    If position_three_A <> "E" Then
                        position_three = position_three - 1
                        position_four = position_four + 1
                        position_five = position_five - 1
                        position_six = position_six + 1
                        ElseIf position_three_A = "E" Then
                        position_three = 32
                    Else
                        If position_two_A <> "11" Then
                            position_two = position_two + 1
                            position_three = position_three - 1
                            position_four = position_four + 1
                            position_five = position_five - 1
                            position_six = position_six + 1
                            ElseIf position_two_A = "11" Then
                            position_two = 0
                        Else
                            If position_one <> "11" Then
                                position_one = position_one + 1
                                position_two = position_two + 1
                                position_three = position_three - 1
                                position_four = position_four + 1
                                position_five = position_five - 1
                                position_six = position_six + 1
                            ElseIf position_one <> "0" Then
                                position_one = 0
                               end If
                        End If
                    End If
                End If
            End If
        End If

Open in new window

0
skywaker
Asked:
skywaker
1 Solution
 
evilrixSenior Software Engineer (Avast)Commented:
It's going to be something like below, although you'll  obviously need to sanity check the logic as I don't have nor use VB :)
#include <string>
 
int main()
{
	std::string position_six_A;
	std::string position_five_A;
	std::string position_four_A;
	std::string position_three_A;
	std::string position_two_A;
	size_t position_one;
	size_t position_two;
	size_t position_three;
	size_t position_four;
	size_t position_five;
	size_t position_six;
 
 
 
	if(position_six_A != "11")
	{
		position_six = position_six + 1;
	}
	else
	if(position_six_A == "11")
	{
		position_six = 0;
	}
	else
	if(position_five_A != "E")
	{
		position_five = position_five - 1;
		position_six = position_six + 1;
	}
	else
	if(position_five_A == "E")
	{
		position_five = 32;
	}
	else
	if(position_four_A != "11")
	{
		position_four = position_four + 1;
		position_five = position_five - 1;
		position_six = position_six + 1;
	}
	else
	if(position_four_A == "11")
	{
		position_four = 0;
	}
	else
	if(position_three_A != "E")
	{
		position_three = position_three - 1;
		position_four = position_four + 1;
		position_five = position_five - 1;
		position_six = position_six + 1;
	}
	else
	if(position_three_A == "E")
	{
		position_three = 32;
	}
	else
	if(position_two_A != "11")
	{
		position_two = position_two + 1;
		position_three = position_three - 1;
		position_four = position_four + 1;
		position_five = position_five - 1;
		position_six = position_six + 1;
	}
	else
	if(position_two_A == "11")
	{
		position_two = 0;
	}
	else
	if(position_one != 11)
	{
		position_one = position_one + 1;
		position_two = position_two + 1;
		position_three = position_three - 1;
		position_four = position_four + 1;
		position_five = position_five - 1;
		position_six = position_six + 1;
	}
	else
	if(position_one != 0)
	{
		position_one = 0;
	}
}

Open in new window

0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now