在一行中输入两个不同的值

2 different input value in 1 line

本文关键字:两个 输入 一行      更新时间:2023-10-16

谁能帮助我如何做或获得2个输入,接受2个不同的值在同一时间。

图中红色方块M2是我输入的INPUT,那么如果我输入M1就会得到价格为10.50的Milk。

下面是示例输入

据我所知,您正在尝试使用一行或另一行的输入和输出。只需使用if语句就可以很容易地做到这一点。例如:

#include <iostream>
using namespace std;
int main() {
    string INPUT;
    cout << "The beginning of your code (the table, information, selection, and 'item selected:')";
    cin >> INPUT;
    if (INPUT == "possible inputs") {
        cout << "Cash amount:" << price;
    }
}