Home > Back-end >  The 11th blue bowl individual campus E problem a method
The 11th blue bowl individual campus E problem a method

Time:01-09


E: a positive integer if any digital not greater than the right adjacent, is called a digital increasing number, such as the number 1135 is a digital incremental, and not a digital incremental number 1024,
Given a positive integer n, could you tell me in how many of the integers 1 to n a digital incremental number?
The original poster is a novice, here is the method of solution for this problem is
# include
# include
Int bj (int n);
Int main ()
{
Int x, c=0, t;
The scanf (" % d ", & amp; X);
For (t=1; T<=x; T++)
{if (bj (t)==1)
C + +;
}
Printf (" % d ", c);

}
Int bj (int n)
{
Int I=0, j, flag=1;
Int a, [6].
While (1)
{if (n>=10)
A [I]=n % 10;
The else
{a [I]=n;
break;
}
N=n/10;
i++;
}
for(j=0; J<=I; J++)
{if (a [j] flag=0;
}
Return flag;

}

May be a bit messy, way of thinking is to define an array, a function, use an array to n each store, and then from bits to compare with the number one by one on the left,

CodePudding user response:

I run the feel no problem, please see if there is a more simple method

CodePudding user response:

Reference:
 # include 
Bool bj (int n);

Int main (int arg c, char * argv [])
{
Int x, c=0, t;
The scanf (" % d ", & amp; X);
For (t=1; T<=x; T++)
If (bj (t)) c + +;
Printf (" % d ", c);

return 0;
}


Bool bj (int n)
{
Int j, k;
K=n % 10;
While (n) {
M=n % 10;
If (m> K) return false.
K=m;
N/a=10;
}
return true;
}

CodePudding user response:

Judging function and then a brief step:
 bool bj (int n) 
{
Int j, k=n % 10;
While (n=10)/{
M=n % 10;
If (m> K) return false.
K=m;
}
return true;
}

CodePudding user response:

Thank you bosses give directions, but why I generate solutions to make a mistake, I am using vc + + 2010, bool is what kind, I have never seen a

CodePudding user response:

Vc in the BOOL type, you try to BOOL, false in the function body into a false, true to true,
1, different types of
Custom types: BOOL type int, Microsoft typedef int BOOL;
Bool for Boolean, for c + + standard data type
2, different length
Bool is only one byte
BOOL length to be decided according to actual conditions, can generally be considered 4 bytes, because it is itself an int type
3, different values
Boolean value of false and true, and it is the difference between 0 and 1
Boolean value of FALSE and TRUE, and it is the difference between zero and non-zero
If several columns bool objects together, may each have a bit, depending on the compiler,
BOOL is defined by Microsoft typedef int BOOL) (in windef. J h, unlike BOOL, three value logic, it is a TRUE/FALSE/ERROR,

CodePudding user response:

Vc in the BOOL type, you try to BOOL, false in the function body into a false, true to true,
1, different types of
Custom types: BOOL type int, Microsoft typedef int BOOL;
Bool for Boolean, for c + + standard data type
2, different length
Bool is only one byte
BOOL length to be decided according to actual conditions, can generally be considered 4 bytes, because it is itself an int type
3, different values
Boolean value of false and true, and it is the difference between 0 and 1
Boolean value of FALSE and TRUE, and it is the difference between zero and non-zero
If several columns bool objects together, may each have a bit, depending on the compiler,
BOOL is defined by Microsoft typedef int BOOL) (in windef. J h, unlike BOOL, three value logic, it is a TRUE/FALSE/ERROR,

CodePudding user response:

Thank you, the few compiler recognition not to come out, after changing capital should not be the problem, here is the code images and generate an error

CodePudding user response:

The first change to BOOL:
 # include 

BOOL bj (int n);

Int main (int arg c, char * argv [])
{
Int x, c=0, t;
The scanf (" % d ", & amp; X);
For (t=1; T<=x; T++)
If (bj (t)) c + +;
Printf (" % d ", c);

return 0;
}


BOOL bj (int n)
{
Int j, k=n % 10;
While (n=10)/{
M=n % 10;
If (m> K) return FALSE.
K=m;
}
return TRUE;
}


The second change to int type:
 # include 

Int bj (int n);

Int main (int arg c, char * argv [])
{
Int x, c=0, t;
The scanf (" % d ", & amp; X);
For (t=1; T<=x; T++)
If (bj (t)) c + +;
Printf (" % d ", c);

return 0;
}


Int bj (int n)
{
Int j, k=n % 10;
While (n=10)/{
M=n % 10;
If (m> K) return 0;
K=m;
}
return 1;
}

CodePudding user response:

Line 2, line 15 suggest there is a grammar mistakes, check under '; "What is the Angle or half Angle,

CodePudding user response:

The code above you copy and paste directly to your editor window,
  • Related