Răspuns:
#include <iostream>
using namespace std;
int nr_cif(int x)
{
int nr=0;
do{
nr++;
x=x/10;
}while(x);
return nr;
}
int main()
{
int a,b,k=0;
cin>>a>>b;
if(nr_cif(a)!=nr_cif(b))
cout<<"NU";
else
{
cout<<"DA"<<endl;
while(a>0 && b>0)
{
if(a%10==b%10)
k++;
a/=10;
b/=10;
}
cout<<k;
}
return 0;
}
Explicație: