#include <iostream>
using namespace std;
int main(){
int n;
while(cin>>n)
if(n==0){
cout<<"yes"<<endl;
}
else{
if(n%3==0){
cout<<"yes"<<endl;
}
else{
cout<<"no"<<endl;
}
}
return 0;
}
#include
using namespace std;
int main(){
int n;
while(cin>>n)
if(n==0){
cout<<"yes"<<endl;
}
else{
if(n%3==0){
cout<<"yes"<<endl;
}
else{
cout<<"no"<<endl;
}
}
return 0;
}
大哥,數據可是"超~~大型",你對int的期望會不會太高了?
int範圍: +- 2^32 - 1 (+- 2147483647)
若要判別是否為3的倍數
就判別每一位數相加後,是否為3的倍數
如此一來,用int足以
若有幫助到還煩請您幫我留個言
謝謝囉~~
http://ntnuee40475032h.pixnet.net/blog
#include
using namespace std;
int main(){
int n;
while(cin>>n)
if(n==0){
cout<<"yes"<<endl;
}
else{
if(n%3==0){
cout<<"yes"<<endl;
}
else{
cout<<"no"<<endl;
}
}
return 0;
}
偷偷告訴你 : 測資會給你10個數字喔~
希望對你有幫助