Created
November 15, 2020 06:22
-
-
Save ochilab/a0622c27bd2d3a18ca8118abe250494e to your computer and use it in GitHub Desktop.
C言語による番兵法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int sentinel(){ | |
int test[11]={3,23,5,8,32,6,50,7,4,13}; | |
int target = 50; | |
test[10]=target; //末尾に検索対象を入れる | |
while(1){ | |
if(target==test[i]){ | |
printf("見つかりました\n"); | |
break; | |
} | |
i++ | |
} | |
return i==target?-1:i; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment