Home > other >  Python chicken dish one, again meet two won't work, ask who help me thank you
Python chicken dish one, again meet two won't work, ask who help me thank you

Time:10-08

1. Lets see how the who change a number in

From the 255568 who either staying same or increasing. Lets call this an up number.

From the 9854420 who either staying the same or decreasing. Lets call this a down number.

From the 1357797543321 who going up and then down. We call to a number the an updown number.

A number is valid if its an number of up, down A number or an updown number.

The user will enter a number n. The Output if it is valid.


2
. Ask the user to enter a number n & gt;=1.

Distinct There after the user will enter n - 1 integers between 1 and n. Thus, the rose Numbers contain all Numbers between 1 and n except one. The Output of the missing number.

You are not allowed to use lists. You are also not allowed to use dictionaries or any programming concept more advanced that a loop.

The Numbers rose can be in any order.


-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Copyright statement: this article to CSDN blogger (lzy841398007) of the original articles, follow BY CC 4.0 - SA the copyright agreement, reproduced and this statement, please attach the original source link
The original link: https://blog.csdn.net/lzy841398007/article/details/103416348

CodePudding user response:

Don't sink to save the children

CodePudding user response:

 
Def checkNum (num) :
The state=None
Times=0
M=None
While (True) :
If num<10:
N=num
Num=0
The else:
N=10 num %
Num=num//10
If m==None:
M=n
The continue
Elif state==None:
If n & lt; M:
The state=True
M=n
The continue
Elif n> M:
The state=False
M=n
The continue
If (state and n> M) or (not state and nState=not state
Times +=1
If times> 1 the or (times==1 and n> M) :
Return False
If num==0:
Return True
M=n

Print (checkNum (255568))
Print (checkNum (9854420))
Print (checkNum (1357797543321))

Def findNum (n, arr) :
Num=0
While n> 1:
Num=n ^ num ^ arr [n - 2)
N=1
-Return num ^ 1

Print (findNum (5,,2,3,5 [1]))

CodePudding user response:

1

 
Input_num=input (' both Please enter a n:)

Def str_filter (str_n twich) :
"'
The input string,
If if reorder and input are identical, return True
Otherwise, returns False
"'
List_num=list (str_n)
If twich==1:
Sorted_list=sorted (list_num)
Elif twich==2:
Sorted_list=sorted (list_num, reverse=True)
If sorted_list==list_num:
Return True
The else:
Return False

Max_str=Max (sorted (input_num) # the highest value in the input string
Max_str_index=list (input_num). The index (max_str) # maximum string index

# alone a digital output effective
If len (input_num)==1:
Print (' The number is vaild ')

If str_filter (input_num, 1) or str_filter (input_num, 2) :
Print (' The number is vaild ')
Behind a maximum # string the front conforms to ascending, in line with the descending order, is in line with the updown number
Elif str_filter (input_num [: max_str_index], 1) and str_filter (input_num [max_str_index:], (2) :
Print (' The number is vaild ')
The else:
Print (' The number is not vaild ')


By the way the building where is the school?
  • Related