0
配列内の番号の場所を見つけようとするプログラムを入力しようとするとエラーが発生します。入力全体を に伝えたいのですが、簡単な方法はありますか?ありがとうございました。 pycharmにコンソールで実行しようとすると、私は 次のエラーを取得するpycharmに複数の行を入力
例
入力
pycharmコンソールで# Returns index of x in arr if it is present,
# else returns -1
def search(arr, x):
n = len(arr)
for j in range(0,n):
if (x == arr[j]):
return j
return -1
# Input number of test cases
t = int(raw_input())
# One by one run for all input test cases
for i in range(0,t):
# Input the size of the array
n = int(raw_input())
# Input the array
arr = map(int, raw_input().split())
# Input the element to be searched
x = int(raw_input())
print(search(arr, x))
私の入力:入力文字列Bcoz
2
4
1 2 3 4
3
5
10 90 20 30 40
40
出力
Traceback (most recent call last):
File "<input>", line 8, in <module>
ValueError: invalid literal for int() with base 10: '2\n 41 2 3 4\n 3\n 5\n 10 90 >20 30 40\n 40'
pycharmで解析する代わりに、値を入力するだけの方法があります。どのように競争的なプログラムでこれに取り組むでしょうか – skywalker