#27429: NA80%看這裡


fdhs_108OuOb (白熊ʕ •ᴥ•ʔ)


溢位或者除以0的錯誤!! 
Floating point exception (core dumped)

就跟上面說的一樣
不過不是溢位,是因為除以0
直接另外判斷除以0輸出OK就好
#28488: Re:NA80%看這裡


Ivan20092009 (cloveت)


溢位或者除以0的錯誤!! 
Floating point exception (core dumped)

就跟上面說的一樣
不過不是溢位,是因為除以0
直接另外判斷除以0輸出OK就好


請問這樣哪裡有錯???

#include <bits/stdc++.h>

 

using namespace std;

int main()

{

int a,b;

while(cin>>a>>b)

if(a%b!=0)

cout<<a%b;

else if(a%b==0)

cout<<"OK!";

 

}

 

謝謝

 

#28489: Re:NA80%看這裡


linlincaleb@gmail.com (臨末之頌)


溢位或者除以0的錯誤!! 
Floating point exception (core dumped)

就跟上面說的一樣
不過不是溢位,是因為除以0
直接另外判斷除以0輸出OK就好


請問這樣哪裡有錯???

#include <bits/stdc++.h>

 

using namespace std;

int main()

{

int a,b;

while(cin>>a>>b)

if(a%b!=0)

cout<<a%b;

else if(a%b==0)

cout<<"OK!";

 

}

 

謝謝

 

b=0

#30868: Re: NA80%看這裡


11051114 (207-13洪本元)


溢位或者除以0的錯誤!! 
Floating point exception (core dumped)

就跟上面說的一樣
不過不是溢位,是因為除以0
直接另外判斷除以0輸出OK就好

還不是錯了

#include <iostream>
using  namespace std;

int main()
{
int a,b;
cin>>a>>b;
int c;
c=a%b;
if(c==0) cout<<"OK!"<<endl;
if(c!=0) cout<<c<<endl;
if(b==0) cout<<"OK!"<<endl;
return 0;
}

#30900: Re: NA80%看這裡


jasonchiang1128@gmail.com (江杰恩)


溢位或者除以0的錯誤!! 
Floating point exception (core dumped)

就跟上面說的一樣
不過不是溢位,是因為除以0
直接另外判斷除以0輸出OK就好

還不是錯了

#include
using  namespace std;

int main()
{
int a,b;
cin>>a>>b;
int c;
c=a%b;
if(c==0) cout<<"OK!"<if(c!=0) cout<if(b==0) cout<<"OK!"<return 0;
}

我這程式AC,可以參考一下

#30901: Re: NA80%看這裡


jasonchiang1128@gmail.com (江杰恩)


溢位或者除以0的錯誤!! 
Floating point exception (core dumped)

就跟上面說的一樣
不過不是溢位,是因為除以0
直接另外判斷除以0輸出OK就好

還不是錯了

#include
using  namespace std;

int main()
{
int a,b;
cin>>a>>b;
int c;
c=a%b;
if(c==0) cout<<"OK!"}

我這程式AC,可以參考一下

#include<cstdio>
#include<iostream>
#include<stdlib.h>
#include<string>
using namespace std;
int main()
{
    int a,b;
    cin >> a;
    cin >> b;
    if(b == 0)
    {
        cout << "OK!" << endl;
        return 0;
    }
    if(a % b == 0)
    {
        cout << "OK!" << endl;
    } else {
        cout << a % b << endl;
    }
    
}