사용자가 2D 배열의 크기를 만든 다음 각 배열 공간을 채우기 위해 숫자를 입력 할 수있게하는 코드를 만듭니다. 그런 다음 학교 프로젝트의 Magic Square인지 확인해야하지만 위의 두 가지 오류가 계속 발생합니다. 여기 Xcode 오류 : 아키텍처 x86_44에 대한 정의되지 않은 기호 및 아키텍처에 대한 기호가 없습니다. x86_64
내 전체 코드입니다 :#include <iostream>
bool isMagicSquare(int row, int col, int magicSquare);
using namespace std;
int main()
{
int row, col;
int input = 0;
cout << "Enter the number of rows: ";
cin >> row;
cout << endl;
cout << "Enter the number of columns: ";
cin >> col;
cout << endl;
int magicSquare[row][col];
if (col != row)
{
cout << "Sorry, this cannot be a magic square." << endl;
cout << "Enter the number of rows: ";
cin >> row;
cout << endl;
cout << "Enter the number of columns: ";
cin >> col;
cout << endl;
}
else if (col == row)
{
for (int i = 0; i < row; i++)
{
for (int j = 0; j < col; j++)
{
cout << "Enter a number for row " << i+1 << " column " << j+1 << ": ";
cin >> input;
magicSquare[i][j] = input;
}
}
}
isMagicSquare(row, col, magicSquare[row][col]);
{
if (isMagicSquare(row, col, magicSquare[row][col]) == true)
{
cout << "This is a magic square." << endl;
}
if (isMagicSquare(row, col, magicSquare[row][col]) == false)
{
cout << "This is not a magic square." << endl;
}
}
return 0;
}
bool isMagicSquare(int row, int col, int magicSquare[row][col])
{
int rowTotal, colTotal, diagA, diagB;
rowTotal = 0;
colTotal = 0;
diagA = 0;
diagB = 0;
for (int r = 0; r < row; r++)
{
rowTotal = 0;
for (int c = 0; c < col; c++)
{
rowTotal += magicSquare[r][c];
}
}
for (int c = 0; c < col; c++)
{
colTotal = 0;
for (int r = 0; r < row; r++)
{
colTotal += magicSquare[ r ][ c ];
}
}
for (int r = 0; r < row; r++)
{
diagA += magicSquare[r][r];
}
for (int i = 0; i < row; i++)
{
diagB += magicSquare[i][i];
}
if (rowTotal != colTotal)
{
return false;
}
else if (diagA != rowTotal)
{
return false;
}
else if (diagB != rowTotal)
{
return false;
}
return true;
}
여기에 전체의 오류 메시지입니다 : 나는 시도하고 문제를 해결하기 위해 여러 가지를 시도했습니다
Ld /Users/macintosh/Library/Developer/Xcode/DerivedData/project_5_new-fwiwizttrvaiwxesfsfyyahdetpv/Build/Products/Debug/project\ 5\ new normal x86_64 cd "/Users/macintosh/Desktop/project 5 new" export MACOSX_DEPLOYMENT_TARGET=10.10 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -L/Users/macintosh/Library/Developer/Xcode/DerivedData/project_5_new-fwiwizttrvaiwxesfsfyyahdetpv/Build/Products/Debug -F/Users/macintosh/Library/Developer/Xcode/DerivedData/project_5_new-fwiwizttrvaiwxesfsfyyahdetpv/Build/Products/Debug -filelist /Users/macintosh/Library/Developer/Xcode/DerivedData/project_5_new-fwiwizttrvaiwxesfsfyyahdetpv/Build/Intermediates/project\ 5\ new.build/Debug/project\ 5\ new.build/Objects-normal/x86_64/project\ 5\ new.LinkFileList -mmacosx-version-min=10.10 -stdlib=libc++ -Xlinker -dependency_info -Xlinker /Users/macintosh/Library/Developer/Xcode/DerivedData/project_5_new-fwiwizttrvaiwxesfsfyyahdetpv/Build/Intermediates/project\ 5\ new.build/Debug/project\ 5\ new.build/Objects-normal/x86_64/project\ 5\ new_dependency_info.dat -o /Users/macintosh/Library/Developer/Xcode/DerivedData/project_5_new-fwiwizttrvaiwxesfsfyyahdetpv/Build/Products/Debug/project\ 5\ new
Undefined symbols for architecture x86_64: "isMagicSquare(int, int, int)", referenced from: _main in main.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
하지만, 발견 해결책 없음. 도와주세요!
입니다! 고마워요, 하루 종일 노예 였어요. 정말 고마워요. –
이 질문에 대한 대답이 정답이면 .... – gman