2 years ago

#67679

test-img

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.

Here is the issue: enter image description here

The thing is, it is not displaying the "100 occurs 3 times", it just displays when I write another number: enter image description here

Here is another example: enter image description here

Not showing the output until I write another number: enter image description here

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

Accepted video resources