#14814: 為甚麼是WA


Eric7654321 (Dr. Kiwi)


#include <iostream>
#include <cmath>

using namespace std;

int main()
{
int time,x,y,r,yee,d;
cin >> time;
for(time==time;0<time;time--){
cin >> x >> y;
r=sqrt( ( x - 0 ) + ( y - 0 ) );
yee=100-r*r;
if(yee>0 && yee<=30){
cout << "sad!" << endl;
}
else if(yee>30 && yee<=60){
cout << "hmm~~" << endl;
}
else if(yee>60 && yee<100){
cout << "Happyyummy" << endl;
}
else{
cout << "evil!!" << endl;
}
}

return 0;
}

這樣子哪裡錯了!

#14816: Re:為甚麼是WA


kev8067@gmail.com (卓承緯)


#include
#include

using namespace std;

int main()
{
int time,x,y,r,yee,d;
cin >> time;
for(time==time;0<time;time--){
cin >> x >> y;
r=sqrt( ( x - 0 ) + ( y - 0 ) );
yee=100-r*r;
if(yee>0 && yee<=30){
cout << "sad!" << endl;
}
else if(yee>30 && yee<=60){
cout << "hmm~~" << endl;
}
else if(yee>60 && yee<100){
cout << "Happyyummy" << endl;
}
else{
cout << "evil!!" << endl;
}
}

return 0;
}

這樣子哪裡錯了!

提示: 變數型態會影響結果的進位與不進位