1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);cin.tie(0);
int n,m,co=0;
cin>>n>>m;
for(int i=n; i<=m; i++)
{
vector<int>v;
while(i>0)
{
int rem = i%10;
i=i/10;
v.push_back(rem);
}
int flag=0;
for(int j=0; j<v.size(); j++)
{
for(int k=1; k<v.size(); k++)
{
if(v[j]==v[k])
{
flag=1;
break;
}
}
}
if(flag==0)
co++;
}
cout<<co<<endl;
return 0;
}
|
Last edited on
The innermost loop increments j instead of k.
The while loop sets i to 0 so the outermost loop never stops.
@Peter87
I've Fixed that..but still not giving output.