C++ 我不明白你在做什么

C++ 我不明白你在做什么,c++,loops,C++,Loops,所以我试着做了我的第一个控制台应用程序,但由于我不明白do-while循环是如何工作的,所以它有点失败 #include <iostream> int balance = 100; int pay = 30; int awnser; // Variables for the awnsers int withdrawal; int a = 1; int main() { do { std::cout << "\n Whats the acti

所以我试着做了我的第一个控制台应用程序,但由于我不明白do-while循环是如何工作的,所以它有点失败

#include <iostream>

int balance = 100;
int pay = 30;
int awnser;

// Variables for the awnsers
int withdrawal;
int a = 1;


int main() {
    do {
        std::cout << "\n Whats the action you wanna do? \n 1 = Check balance \n 2 = Withdraw money \n 3 = Deposit money \n 4 = Check transaction history \n 5 = Exit \n";
        std::cout << " ";
        std::cin >> awnser;

        if (awnser == 1) {
            std::cout << balance << " Euros\n \n";
        }

        if (awnser == 2) {
            std::cout << "How much do you wanna with draw?\n";
            std::cin >> withdrawal;
            if (withdrawal > balance)
                std::cout << "You dont have that much money.\n \n";
            else {

                std::cout << "Your current balance is: " << balance - withdrawal;

            }

        }

        if (awnser == 3) {
            std::cout << "We know you dont have enymore daam money you beggar so dont even try that\n \n";
        }

        if (awnser == 4) {


        }

        if (awnser == 5) {
            std::cout << "Enter 0 to exit or 1 to go back\n";
            std::cin >> a;
        }
        else if (a == 1) {
            std::cout << "\n";
            return 1;

        }


    } while (a == 1);

}
#包括
国际收支平衡=100;
int pay=30;
内芒塞尔;
//应用程序的变量
int提取;
INTA=1;
int main(){
做{
std::cout-awnser;
如果(awnser==1){
标准::库特天平)

std::cout如果输入的数字不是您检查的数字(1到5),则您点击:

else if (a == 1) {
    std::cout << "\n";
    return 1;
}
else如果(a==1){

std::我可以推荐使用调试器吗。这样你可以一次执行一行程序,在每个步骤中查看变量并了解执行流程。
否则,如果(a==12)…返回1;
是原因。另外,它是拼写的答案。
return 1;
in
main()
表示结束程序。如果
a==1
返回;可能就是这种情况,
a
的意义是什么?此外,您可能希望使用
开关而不是
If
s。