Primer C++

#include<iostream>
using namespace std;
int main()
{
    int curval = 0, val = 0;
    if (cin >> curval)//确保第一个数
    {
        int count = 1;
        while (cin >> val)  //一直检测输入int,直到遇到非int或者windows下的ctrl+z
        {
            if (val == curval)
            {
                ++count;

            }
            else {
                cout << "the num of " << curval << " show time is " << count << endl;
                curval = val;
                count = 1;
            }

        }
        cout << "the num of " << curval << " show time is " << count << endl;
    }
    return 0;
}

空指针

 指针和赋值

 

原文地址:https://www.cnblogs.com/yangj-Blog/p/14307644.html