早教吧作业答案频道 -->其他-->
acmHDU1084报错为RuntimeError(ACCESSVIOLATION)#include#include#include#include#defineN100+10usingnamespacestd;structstudent{intslove;stringtime;intidx;intscore;};structstudenta[N];boolcmp1(studenta,studentb){if(a.slove=b.s
题目详情
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.
看了 acmHDU1084报错为R...的网友还看了以下:
提示:D-C=0A-B,A-D,D-C,D-E,E-F=1A-D,C-F=2A-B,D-E,E-F 2020-04-06 …
已知字母组合成英语单词1、e e t t i n h r 2、e e r a t w h 3、o 2020-05-14 …
实体-联系模型(简称E-R模型)中的基本语义单位是实体和联系。E-R模型的图形表示称为E-R图。联系 2020-05-26 …
E^2*R/(R+r)^2=E^2/(R-r)^2/R+4r(某公式推导最后两行)本人只得:=E^ 2020-06-07 …
main(){unionEXAMPLE{struct{intx,y;}in;inta,b;}e;e 2020-06-12 …
用以下英文宇母填在上a,a,a,a,a,a,b,e,e,d,e,e,e,e,e,e,f,g,g用以 2020-06-24 …
如图所示,电路中E=3V,r=0.5Ω,R0=1.5Ω,变阻器R的最大阻值为10Ω.(1)在变阻器 2020-07-15 …
2-1设文法G[E]的产生式集为:EàE+T|E-T|TTàT*F|T/F|FFà(E)|i(1)给 2020-11-26 …
老师讲的是用来求额定电压的还有学到求电池E和r的时候讲到E真>E测的时候除了图像法老师说的另一种方法 2020-12-26 …
如图所示,用伏安法测电阻R的阻值时,下列说法正确的是()A.十分认真地进行测量,测量所得R值一定仍比 2020-12-31 …