最近遇到一个问题……
我是主攻前端的,但后端也不是不会,最近在用据说是最好的C++编译器CLion,然后就出错了!
#include <iostream>
using namespace std;
int n, m, x, sum = 0;
struct student {
int id, score;
};
int main() {
student st[32767];
cin >> n >> m;
for (int i = 0; i <= n - 1; i++) {
cin >> st[i].id >> st[i].score;
}
for (int i = 0; i < n - 1; i++) {
for (int j = i + 1; j < n; j++) {
if (st[i].score > st[j].score) {
swap(st[i], st[j]);
} else if (st[i].score == st[j].score) {
if (st[i].id < st[j].id) {
swap(st[i], st[j]);
}
}
}
}
x = m / 10 * 15;
for (int i = 0; i < n; i++) {
if (st[i].score >= x) {
sum++;
}
}
cout << x << sum << endl;
return 0;
}
这代码应该是没问题的,但就是运行不了(悲)
它报的这个错:
====================[ Build | C___Practice | Debug ]============================
"E:\NO NAME\SOFTWARES\CLion 2022.3\bin\cmake\win\bin\cmake.exe" --build "E:\NO NAME\PROGRAMMING\C++-Practice\cmake-build-debug" --target C___Practice -j 3
[1/1] Linking CXX executable C___Practice.exe
FAILED: C___Practice.exe
cmd.exe /C "cd . && E:\NONAME1\SOFTWA1\CLION21.3\bin\mingw\bin\G__1.EXE -g CMakeFiles/C___Practice.dir/HelloWorld.cpp.obj CMakeFiles/C___Practice.dir/Contests/Score_Judging.cpp.obj -o C___Practice.exe -Wl,--out-implib,libC___Practice.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
E:\NO NAME\SOFTWARES\CLion 2022.3\bin\mingw\bin/ld.exe: CMakeFiles/C___Practice.dir/Contests/Score_Judging.cpp.obj:E:/NO NAME/PROGRAMMING/C++-Practice/Contests/Score Judging.cpp:10: multiple definition of `main'; CMakeFiles/C___Practice.dir/HelloWorld.cpp.obj:E:/NO NAME/PROGRAMMING/C++-Practice/HelloWorld.cpp:4: first defined here
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
哪位高人能帮我解答下?本蒟蒻会感激涕零!