Ok this is an program to input numbers and show how many times numbers are repeated or not. Program code is below.....
#include<iostream>
int main()
{
int currval=0,val=0;
if(std::cin>>currval)
{
int cnt=1;
while(std::cin>>val)
{
if(currval==val)
{
++cnt;
}
else
{
std::cout<<currval<<" occurs "<<cnt<<" times. "<<std::endl;
currval=val;
cnt=1;
}
}
Aucun commentaire:
Enregistrer un commentaire