acm HDU 1084 报错为Runtime Error(ACCESS_VIOLATION)
来源:学生作业帮 编辑:灵鹊做题网作业帮 分类:综合作业 时间:2024/05/16 09:06:02
acm HDU 1084 报错为Runtime Error(ACCESS_VIOLATION)
#include
#include
#include
#include
#define N 100+10
using namespace std;
struct student
{
int slove;
string time;
int idx;
int score;
};
struct student a[N];
bool cmp1(student a,student b)
{
if (a.slove = b.slove)
return a.slove > b.slove;
else
a.time < b.time;
}
bool cmp2(student a,student b)
{
return a.idx < b.idx;
}
int main()
{
int n,i,slovenum[6];
int p1 = 0,p2 = 0,p3 = 0,p4 = 0;
while (cin>> n&&n = -1)
{
memset(slovenum,0,sizeof(slovenum));
for (i = 0;i < n;i++)
{
cin >> a[i].slove >> a[i].time;
a[i].idx = i + 1;
slovenum[a[i].slove]++;
}
sort(a,a + n,cmp1);
for (i = 0;i
#include
#include
#include
#include
#define N 100+10
using namespace std;
struct student
{
int slove;
string time;
int idx;
int score;
};
struct student a[N];
bool cmp1(student a,student b)
{
if (a.slove = b.slove)
return a.slove > b.slove;
else
a.time < b.time;
}
bool cmp2(student a,student b)
{
return a.idx < b.idx;
}
int main()
{
int n,i,slovenum[6];
int p1 = 0,p2 = 0,p3 = 0,p4 = 0;
while (cin>> n&&n = -1)
{
memset(slovenum,0,sizeof(slovenum));
for (i = 0;i < n;i++)
{
cin >> a[i].slove >> a[i].time;
a[i].idx = i + 1;
slovenum[a[i].slove]++;
}
sort(a,a + n,cmp1);
for (i = 0;i
有几个隐蔽的小错误:
一是,没有写return
bool cmp1(student a,student b)
{
if (a.slove != b.slove)
return a.slove > b.slove;
else
a.time < b.time; <- 这里
}
二是,题目中只说了负数,没说是-1结束
while (cin>> n&&n != -1) 改为 n >= 0
三是,pX没有初始化:
memset(slovenum, 0, sizeof(slovenum));
这里应把p1,p2,p3,p4也初始化为0.
再问: 那请问这种报错的话一般是因为什么
一是,没有写return
bool cmp1(student a,student b)
{
if (a.slove != b.slove)
return a.slove > b.slove;
else
a.time < b.time; <- 这里
}
二是,题目中只说了负数,没说是-1结束
while (cin>> n&&n != -1) 改为 n >= 0
三是,pX没有初始化:
memset(slovenum, 0, sizeof(slovenum));
这里应把p1,p2,p3,p4也初始化为0.
再问: 那请问这种报错的话一般是因为什么
acm HDU 1084 报错为Runtime Error(ACCESS_VIOLATION)
HDU ACM problem 1236 为什么会Runtime Error (ACCESS_VIOLATION)?
ACM HDU 1002 A + B Problem II Runtime Error(ACCESS_VIOLATION
hdu acm 第1592题哪里错了?代码如下,错误是 runtime error
Runtime Error!
ACM 题 简单的dp 但一直提示 Runtime Error(Segment Fault) 求指导
Runtime Error 求知道!
Runtime Error是什么意思
"runtime error ,abnormal program termination"翻译为中文是什么意思?
HDU ACM编程2000题..
hdu acm 难度分布问题
升级时显示:Runtime Error!