1. You understand python syntax
2. You understand what the algorithm actually does
3. You understand C++ syntax
leads to:
4. You write C++ code that implements the same algorithm
i don't understand how to move a python to c++.....i have try it...but it can't to run because have many error....please help me....i can't do that...and i don't understand
Python and C++ are two different languages. To translate one language to another you need to have knowledge of both languages. It might not be as simple as just changing line by line, but could require bigger structural changes.
@ OP, post the python code and your C++ code and we can help you to understand. Without the code, it is hard to know what specific issues you are having.
my python code...i want to move from phyton to c++
print "Welcome To The Resistor Calculator"
print "Our Group Members\nMuhammad Harith Bin Kamlyzan\nMuhammad Hisyam Bin Harmizon\nIkhwan Hakim Bin Mohd Asri\nShahrul Izwan Bin Kamal Akhball\nMuhammad Shahzlan Bin Mohd Nizam"
start = raw_input("Press Enter To Start")
first_colours = {"Black","Brown","Red","Orange","Yellow","Green","Blue","Purple","Grey","White"}
while True:
first_colour = raw_input("\nPlease State The First Colour Band\nBlack\nBrown\nRed\nOrange\nYellow\nGreen\nBlue\nPurple\nGrey\nWhite\nYour Choice?\n")
second_colours = {"Black","Brown","Red","Orange","Yellow","Green","Blue","Purple","Grey","White"}
while True:
second_colour = raw_input("\nPlease State The Second Colour Band\nBlack\nBrown\nRed\nOrange\nYellow\nGreen\nBlue\nPurple\nGrey\nWhite\nYour Choice?\n")
third_colours = {"Black","Brown","Red","Orange","Yellow","Green","Blue","Purple","Grey","White"}
while True:
third_colour = raw_input("\nPlease State The Third Colour Band\nBlack\nBrown\nRed\nOrange\nYellow\nGreen\nBlue\nPurple\nGrey\nWhite\nYour Choice?\n")
fourth_colours = {"Gold","Silver","None"}
while True:
fourth_colour = raw_input("\nPlease State The Fourth Colour Band\nGold\nSilver\nNone\nYour Choice?\n")
total = second_colour*third_colour
print "The Total Value Of Your Resistor Is : " + str(first_colour) + str(total) + " +-" + str(fourth_colour) + '%\n'
exitprogram = raw_input ("\nPress Enter To Exit")
in your case, you define string array , you are using the == operator , in cpp you must specify the type when you declare a variable unless you are using the auto keyword. Even thought there might be ambiguity. The : would be replace by {} for its scope. At the end of every instruction you must have a ; for your raw_input use std::cout << "blabla"; and then put a string value; std::cin >> value; then you compare that value. There is more to say I am just pointing some here. Good luck. If you want my advise , write pseudocode to help you out.
Writing the names of everyone who is asking people on he internet to do their homework for them ( Muhammad Harith Bin Kamlyzan, Muhammad Hisyam Bin Harmizon, Ikhwan Hakim Bin Mohd Asri, Shahrul Izwan Bin Kamal Akhball, Muhammad Shahzlan Bin Mohd Nizam ) probably isn't a great idea.