#20609: 解決RE (SIGSEGV)


a0931097847@gmail.com (謝承恩)

學校 : 不指定學校
編號 : 109542
來源 : [42.72.128.82]
最後登入時間 :
2019-12-15 20:48:15
a291. nAnB problem | From: [42.72.190.226] | 發表日期 : 2020-02-12 02:26

如題

請問該怎麼debug,我用DEV C++編譯都過

感恩各位大神

程式碼:

#include<iostream>
using namespace std;
int main(){
int arr[4];
while(cin >> arr[0] ){
cin >> arr[1] >> arr[2] >> arr[3];
int times,i,j,countA=0,countB=0,temp[4],arr1[4];
cin >> times;
for(j=0;j<times;j++){
countA=0,countB=0;
for(i=0;i<times;i++){
cin >> arr1[i];
}
for(i=0;i<times;i++){
temp[i] = arr[i];
}
for(i=0;i<times;i++){
if(arr1[i]==arr[i]){
countA++;
arr[i]=10;
arr1[i]=11;
}
}
if(arr1[0]==arr[1] || arr1[0]==arr[2] || arr1[0]==arr[3]){
countB++;
// cout << arr1[0] << endl;
}
if(arr1[1]==arr[0] || arr1[1]==arr[2] || arr1[1]==arr[3]){
countB++;
// cout << arr1[1] << endl;
}
if(arr1[2]==arr[1] || arr1[2]==arr[0] || arr1[2]==arr[3]){
countB++;
// cout << arr1[2] << endl;
}
if(arr1[3]==arr[1] || arr1[3]==arr[2] || arr1[3]==arr[0]){
countB++;
// cout << arr1[3] << endl;
}
cout << countA <<"A" <<countB << "B" << endl;
for(i=0;i<times;i++){
arr[i] = temp[i];
}
}

}
return 0;
}

 
ZeroJudge Forum