151k views
4 votes
Problem 1: Triple + Double = So Much Trouble

Write a program that reads two integers, checks if a digit repeats 3 times in a row in the first integer and that same digit repeats two times in a row in the second integer.


Sample input/output:

Enter two integers: 3555761 72559

There are 3 conservative digits 5 in 3555761 and 2 in 72559

User Jagdish
by
5.5k points

1 Answer

3 votes

Answer:

Step-by-step explanation:

The program code is written as:

#include <iostream>

using namespace std;

int main() {

int num1,num2,flag=0,flag1=0,flag_val=0,temp1,temp2,f1,f2,f3,m1,m2;

cout<<"Enter First Number ";

cin>>num1;

cout<<"Enter Second Number ";

cin>>num2;

temp1=num1;

temp2=num2;

while(temp1>0)

{

f1=temp1%10;

temp1=temp1/10;

f2=temp1%10;

if(f1!=f2)

continue;

temp1=temp1/10;

f3=temp1%10;

if(f1==f2 && f2==f3)

{

flag=1;

flag_val=f1;

}

}

while(temp2>0)

{

m1=temp2%10;

temp2=temp2/10;

m2=temp2%10;

if (m1!=m2)

continue;

temp2=temp2/10;

if(m1==m2 && flag==1 && flag_val==m1)

{

flag1=1;

break;

}

}

if (flag1==1)

{

cout<<"Both Number Are Triple + Double";

}

else

{

cout<<"Both number Are not Triple +Double";

}

return 0;

}

OUTPUT:

Enter First Number = 3555761

Enter Second Number = 72559

Both numbers are Triple + DoublePress any key to continue .....

User Shannel
by
4.8k points