In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Two different implementation processes: algorithm-1, algorithm-2.
Compare the logic and efficiency differences of different algorithms, and realize the impact of different implementation processes on the testing method and process.
Software black-box testing and white-box testing are two methods that integrate and complement each other, with exactly the same external results, but their implementation has different methods and efficiency.
Different design ideas, structures and implementation methods should correspond to different testing strategies and methods.
Software testing should not only find errors, but also prevent them. Understanding and analysis are the basic abilities and methods to achieve prediction.
# # algorithm-1 # #
#
#-*-coding: utf-8-*-
# *
# Copyright (c) 2014 Lei Xun Studio
# All Rights Reserved.
#
# File Name: NumCompare.py
# Summary: Compare num W with num X
#
# Question:
# numbers with wildcards: given a number W with a wildcard question mark, the question mark can represent any one digit. Given another integer X, it has the same length as W. Ask how many integers match the form of W and are larger than X.
# input multiple sets of data, each with two rows, the first row is W and the second row is X. they are of the same length. Between [1. 10]. The output format contains an integer per line to represent the result.
# input sample 36 "1" 8 236428 8 "3 910? 5 output sample 1004
#
# @ Version: 1.0
# @ Author: Roy
# @ Date: 04Compact 25Universe 2014
#
# @ Update Version: 1.0
# @ Author:
# @ End Date:
# *
Import re
# global ch
# ch = True
Def checknum (num,n1):
Try:
If num [0] = = '0mm:
Print 'The s is wrong, please input again.' num
Return 0
For i in range (0jinlen (num)):
If (num [I] = = N1) or (int (Numi]) in range (10)):
Continue
Else:
Print 'The s is wrong, please input again.' num
Return 0
Return num
Except:
Print 'Inputting is wrong...'
Return 0
Def getnum ():
# global ch
T = []
While 1:
W = raw_input ('Please input the number W:')
If W = = 'quit':
# ch = False
Break
Return T
Elif checknum (W.J.) = = 0:
# ch = False
Break
Return 0
Else:
T.append (W)
X = raw_input ('Please input the number X:')
If len (W)! = len (X):
Print 'Inputting is wrong, length not equal.'
# ch = False
Break
Return 0
Elif checknum (XGrain0') = = 0:
# ch = False
Break
Return 0
Else:
T.append (X)
Return T
Def comnum (WBI x):
L = len (w)
C = w.count (?)
Cn = 0
S = 0
Tt = [t.start () for t in re.finditer ('\?', w)] #'?' Position in W
For i in range (len (tt)):
If I = = 0:
S = 0
Else:
S = tt [I-1] + 1
If tt [I] = = 0:
Cn = cn + (9-int (x [I])) * (10 minutes * (c-i-1))
Elif s = = tt [I]:
Cn = cn + (9-int (x [I])) * (10 minutes * (c-i-1))
Elif int (w [s: t [I]) > = int (x [s: t [I]]):
Cn = cn + 10 colors * (CMMI)
Else:
Return cn
Return cn
If _ name__ = = "_ _ main__":
Import doctest, NumCompare
G = getnum ()
If len (G)! = 0:
For i in range (len (G) / / 2):
Print comnum (G [I * 2], G [iTunes 2: 1])
Doctest.testmod (NumCompare)
#
# # algorithm-2 # #
#
#-*-coding: utf-8-*-
# *
# Copyright (c) 2014 Lei Xun Studio
# All Rights Reserved.
#
# File Name: NumCompare.py
# Summary: Compare num W with num X
#
# Question:
# numbers with wildcards: given a number W with a wildcard question mark, the question mark can represent any one digit. Given another integer X, it has the same length as W. Ask how many integers match the form of W and are larger than X.
# input multiple sets of data, each with two rows, the first row is W and the second row is X. they are of the same length. Between [1. 10]. The output format contains an integer per line to represent the result.
# input sample 36 "1" 8 236428 8 "3 910? 5 output sample 1004
#
# @ Version: 1.0
# @ Author: Roy
# @ Date: 03Universe 25Universe 2014
#
# @ Update Version: 1.0
# @ Author:
# @ End Date:
# *
Global T,l,c,cn,tc,W,X,p, ml
T = [] # accepte and store varable input
W = [] # get W from T
X = [] # get X from T
L = 0 # length of inputting w
C = 0 # count of'?' In W
Tc = 0 # element's position of W
Cn = 0 # question's result
P = 0 # position of first'?' For W
Def NumCopare (WBI x):
Global l,c,cn,tc,W,X,T,p, ml
If w! ='?' And int (w) not in range (10):
Print ("W3 is incorrect,Please input correct num!\ n")
Return
If int (x) not in range (10):
Print ("X4 is incorrect,Please input correct num!\ n")
Return
If tc
< l : if w != '?' and c != 0: if int(w) >Int (x):
T = int (w)-int (x)
Cn = 10**c*t
# cn = 10 million c
Return cn
Elif int (w)
< int(x): cn = cn + 0 return cn elif int(w) == int(x): tc = tc + 1 NumCopare(W[tc],X[tc]) else: if w == '?': cn1 = 0 cn2 = 0 t = 9 - int(x) cn1 = 10**(c-1)*t tc = tc + 1 c = c -1 if tc < l-1: cn2 = NumCopare(W[tc],X[tc]) cn = cn1 + cn2 return cn def getnum(): global T while 1: # print("*********************** Compare input number ************************") # ww = raw_input('Please input the number W: ') ww = raw_input() wl = len(ww) wc = ww.count('?') if ww == "quit": break elif wc == 0: print("W1 is incorrect,Please input correct num!\n") else: #judge inputting correction for W for i in range(0,len(W)-1): try: int(ww[i]) except(ValueError): if ww[i] != '?': print ("W2 is incorrect,Please input correct num!\n") return T.append(ww) # xx = raw_input('Please input the number X: ') xx = raw_input() xl = len(xx) if xl < wl: print ("X1 is incorrect,Please input correct num!\n") break elif xx.count('?') >0:
Print ("X2 is incorrect,Please input correct num!\ n")
Return
Elif xx [0] ='0' and xl = = wl and xl > 1:
Print ("X3 is incorrect,Please input correct num!\ n")
Return
Else:#judge inputting correction for xx
Try:
Int (xx)
Except (ValueError):
Print ("X4 is incorrect,Please input correct num!\ n")
Return
T.append (xx)
Return T
Def getcount (TT):
Global l,c,W,X,T,p,cn, tc
If TT! = None:
Ll = len (TT)
Else:
Return
For i in range (ll//2):
Tc = 0
Cn = 0
W = []
W = TT [iTun2]
L = len (W)
C = W.count (?)
P = W.find (?)
X = []
X = TT [iTunes 2: 1]
NumCopare (W [0], X [0])
# print "There is" + str (cn) + "W greater than X.\ n"
Print str (cn)
# print getnum ()
If _ name__ = = "_ _ main__":
Import doctest, NumCompare
Getcount (getnum ())
Doctest.testmod (NumCompare)
#
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
Package com.zyhao.openec.util;import java.io.File;import java.io.FileInputStream;import java.io.File
© 2024 shulou.com SLNews company. All rights reserved.