首页 > 代码库 > 统计连续数的个数

统计连续数的个数

#include<iostream>using namespace std;void count(){    int value;    int cnt;    int curvalue;    if(cin>>curvalue)    {        cnt=1;        while(cin>>value)        {            if(curvalue=http://www.mamicode.com/=value)                cnt++;            else            {                cout<<"current value:"<<curvalue<<" total :"<<cnt<<endl;                curvalue=value;                cnt=1;            }        }        cout<<"current value: "<<curvalue<<" total: "<<cnt<<endl;    }}int main(){    count();    return 0;}

运行结果如下: