此 BTC 代码如何验证用户输入?

Arn*_*aba 3 c++

我有这个代码来接受用户输入并验证它以增加用户钱包中的用户 BTC。我需要对这个 CODE 的工作原理进行一些解释。编码:

#include <iostream>
using namespace std;
int main()
{
    int btc_input, result_btc, btc_validation, btc_validation_1_input, btc_validation_2_input;
    result_btc = 0;
    btc_validation = 0;
    btc_validation_1_input = 0;
    btc_validation_2_input = 0;
    for (; btc_validation < 3; btc_validation++)
    {
     cout << "Enter the Value " << (btc_validation + 1) << " + " ;
     cin >> btc_input;
     cout << "Enter the Value " << (btc_validation + 1) << " + " ;
     cin >> btc_input;
     btc_validation_1_input == btc_validation + btc_input;
     cout << "Enter the Value " << (btc_validation_1_input + 1) << " + " ;
     cin >> btc_validation_2_input;
     result_btc = btc_validation_1_input + btc_validation_2_input;
     result_btc *= btc_validation_2_input;
     break;
    }
    cout << result_btc << '\n';
    cout << "Your BTC Wallet is Increased by " << result_btc << " coins " << '\n';
}
Run Code Online (Sandbox Code Playgroud)

Саш*_*аша 5

在任何情况下,您的代码都不是 API,而是代码,请注意诈骗者。您拥有的代码的工作方式与我将通过以最小形式编辑和转换您的代码以便您更好地理解来解释的方式相同。

#include <iostream>
using namespace std;

int main()
{
    int btc_input, result_btc, btc_validation;
    result_btc = 0;
    btc_validation = 0;
    for (; btc_validation < 3; btc_validation++)
    {
     cout << "Enter the number >> [" << btc_validation + 1 << "] " ;
     cin >> btc_input;
     result_btc += btc_input;
    }
    cout << (result_btc *= btc_input) << '\n';
    cout << "You entered " << result_btc << " numbers " << '\n';
}
Run Code Online (Sandbox Code Playgroud)