使用增量的间隔的简单计数器

Simple counter with a interval using increment

本文关键字:简单 计数器      更新时间:2023-10-16

所以我想做一个简单的计数器。我通过做 a = 18 开始了一个版本;和 b = 100;有了这个工作,我的墨水。现在我想让用户定义开始和结束。所以我只是做了一点cout/cin对话。我不知道为什么它不像以前那样工作。

这是我正在使用的代码:

 int a; //start
 a = 0;
 int b; //end
 b = 0;
 cout << "Start eingeben: " << endl; //define start
 cin >> a;
 cout << "Ende eingeben: " << endl; //define end
 cin >> b;
 for(int a ; a <= b; a++){
     cout << a << endl;
 }
for(int a ; a <= b; a++){

定义一个新的a变量,该变量隐藏了您放入值的a。尝试:

for(; a <= b; a++)