因此,首先,我是新手,这可能是我在这里犯的一个非常愚蠢的错误,但是我仍然看不出问题出在哪里。因此,我在这里想要实现的基本上是一个饮料计数器,从本质上讲,您告诉程序您的名字,并且可以为您添加1种饮料。
#include "pch.h"
#include <iostream>
#include <string>
using namespace std;
int Kevin = 0;
int Stephie = 0;
int Erich = 0;
int TomLaurin = 0;
int Christian = 0;
int Torsten = 0;
int Jannis = 0;
int Frederic = 0;
int Phillip = 0;
int Sina = 0;
int Mario = 0;
int Walter = 0;
int main()
{
for (; ; ) {
int Person;
std::cout << "Bitte geben sie ihre Nummer ein: \n";
std::cout << "Kevin = 1 \n";
std::cout << "Stephie = 2 \n";
std::cout << "Erich = 3 \n";
std::cout << "Tom-Laurin = 4 \n";
std::cout << "Christian = 5 \n";
std::cout << "Torsten = 6 \n";
std::cout << "jannis = 7 \n";
std::cout << "Frederic = 8 \n";
std::cout << "Phillip = 9 \n";
std::cout << "Sina = 10 \n";
std::cout << "Mario = 11 \n";
std::cout << "Walter = 12 \n";
scanf_s("%d", &Person);
switch (Person)
{
case 1:
(Kevin + 1);
std::cout << "Das ist dein " << Kevin << ". Getraenk \n";
system("pause");
system("cls");
}
}
}
根据我的理解,应该在输入数字1后打印:“ Das ist dein 1. Getraenk”,但是它的作用是打印:“ Das ist dein 0. Getraenk”
答案 0 :(得分:1)
(Kevin + 1);
-> Kevin++;
或++Kevin
或Kevin += 1;
或Kevin = Kevin + 1;
(Kevin + 1);
无效。