sansnas @ 2022-08-06 14:12:52
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n; cin>>n;
string ct[n-1];
double a[n]={0},b[n]={0};
cin>>a[0]>>b[0];
int x=b[0]/a[0];
for(int i=1;i<n;i++){
cin>>a[i]>>b[i];
int y=b[i]/a[i];
if(x-y>0.05)
ct[i]="worse";
else if(x-y<(-0.05))
ct[i]="better";
else ct[i]="same";}
for(int j=1;j<n;j++)
cout<<ct[j-1]<<" ";
}
有没有佬帮忙查个bug,次次都RE,报received signal11
by HBWH_zzz @ 2022-08-06 14:19:51
首先,int y=b[i]/a[i]
有问题
其次,你的ct
数组开小了,最后一个会爆数组大小
by HBWH_zzz @ 2022-08-06 14:21:09
还有,你要cout回车,不是空格
by caramel_qwq @ 2022-08-06 14:25:15
by caramel_qwq @ 2022-08-06 14:25:29
标题真好
by sansnas @ 2022-08-06 19:05:54
嚯↑↓↑↓↑→
顺便问一下一般报RE(received signal 11:segmentation fault with invalid memory reference)是什么bug(恼)
by noi_sy @ 2022-10-05 17:34:20
@sansnas 数组太小