2 years ago
#67679
Juan Jiménez
Terminal or settings issue
I'm having an issue, maybe with g++ or the debugger, I don't know too much of this, just started coding.
The thing is, it is not displaying the "100 occurs 3 times", it just displays when I write another number:
Not showing the output until I write another number:
I'm I coding something wrong or is it something related to the settings of my PC or anything related, has anyone been in the same situation?
Here is the code just if anyone wants to check it:
#include <iostream>
int main()
{
int currVal = 0, val = 0;
if (std::cin >> currVal)
{
int cnt = 1;
while (std::cin >> val)
{
if (val == currVal)
{
++cnt;
}
else
{
std::cout << currVal << " occurs " << cnt << " times" << std::endl;
currVal = val;
cnt = 1;
}
}
std::cout << currVal << " occurs " << cnt << " times" << std::endl;
}
return 0;
}
c++
terminal
config
0 Answers
Your Answer