Dans l'article de l'examen du tableau Etudier une liste de Python
const int ARRAY_SIZE = 10;
int intArray[ARRAY_SIZE] = {4,5,9,12,-4,0,-57,30987,-287,1};
int targetValue = 12;
int targetPos = 0;
while((intArray[targetPos] != targetValue) && (targetPos < ARRAY_SIZE))
    targetPos++;
 #!/usr/bin/env python
#coding:utf-8
def Search(targetValue):
    ARRAY_SIZE = [4,5,9,12,-4,0,-57,30987,-287,1]
    for x in ARRAY_SIZE:
       if targetValue == x:
           return x
       else:
           continue
    if targetValue != x:
        print("not found")
・ ・ ・ ・(Exécution du terminal)
>>> from test33 import Search
>>> Search(12)
12
>>> 
Quoi qu'il en soit, je pense avec une déclaration if, mais je me demande si tout va bien. Je vais continuer.
Recommended Posts