Home > Back-end >  The two different code, submitted when there is a wrong
The two different code, submitted when there is a wrong

Time:11-08

#include

Int main ()
{
Int l, r, I, k, ans=0;
The scanf (" % d % d ", & amp; L, & amp; r);
For (I=l; i<=r; I++)
For (k=I; K> 0; K/=10)
If (k % 10==2) ans++;
Printf (" % d \ n ", ans);
return 0;
}

#include
using namespace std;
Int main ()
{
Int l, r, I, k, m;
Cin> L & gt;> r;
M=0;
for(i=1; i<=r; I++)
{
For (k=I; K> 0; K/=10)
{
If (10 k %==2)
{
m++;
}
}
}
coutreturn 0;
}

#include
using namespace std;
Int main ()
{
Int l, r, I, k, m;
Cin> L & gt;> r;
M=0;
for(i=1; i<=r; I++)
{
For (k=I; K> 0; K/=10)
{
If (10 k %==2)
{
m++;
}
}
}
coutreturn 0;
}

CodePudding user response:

The
refer to the original poster mawen0502 response:
# include

Int main ()
{
Int l, r, I, k, ans=0;
The scanf (" % d % d ", & amp; L, & amp; r);
For (I=l; i<=r; I++)
For (k=I; K> 0; K/=10)
If (k % 10==2) ans++;
Printf (" % d \ n ", ans);
return 0;
}

#include
using namespace std;
Int main ()
{
Int l, r, I, k, m;
Cin> L & gt;> r;
M=0;
for(i=1; i<=r; I++)
{
For (k=I; K> 0; K/=10)
{
If (10 k %==2)
{
m++;
}
}
}
coutreturn 0;
}

#include
using namespace std;
Int main ()
{
Int l, r, I, k, m;
Cin> L & gt;> r;
M=0;
for(i=1; i<=r; I++)
{
For (k=I; K> 0; K/=10)
{
If (10 k %==2)
{
m++;
}
}
}
coutreturn 0;
}

The outer layer of the first piece of code for loop is [l, r), the second piece of code is the outer for loop [1, r]
  • Related