【发布时间】:2022-12-27 15:05:58
【问题描述】:
#include <iostream>
using namespace std;
int main() {
// your code goes here
int t,x,y,z,set,i,check=0;
cin>>t;
while(t--)
{
cin>>x>>y>>z;
check=z-(x+y);
for(i=0;i<10;i++){
if(check%i==0)
{
set=i;
}
// i++;
}
cout<<set<<endl;
}
return 0;
}
While I run this code then I get run time error like
FLoating point exception
and from next input it gives error like:
dash: 2: 4:not found
【问题讨论】:
-
It is in the
check%iline wheniis0. You have a division by zero exception I think. -
Did you debug your code to see where the exception is being thrown? If you did, then it should be obvious to you as to which line of code is the issue. Just to warn you -- with a rep of 50, not debugging your own code is worthy of a downvote.