#include <bits/stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
string a;
while(cin>>a)
{int c=a.size(),x=0;
for(int i=0;i<c;i++)
{if(a[i]>=97){x+=a[i]-96;}
else {x+=a[i]-38; }}
int k=0;
for(int i=2;i<sqrt(x);i+=(i==2?1:2))
{if(x%i==0){k=1;break;}}
if(k==0){cout<<"It is a prime word."<<endl;}
else cout<<"It is not a prime word."<<endl;}
return 0;
}
請問哪裡錯
#include <bits/stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
string a;
while(cin>>a)
{int c=a.size(),x=0;
for(int i=0;i<c;i++)
{if(a[i]>=97){x+=a[i]-96;}
else {x+=a[i]-38; }}
int k=0;
for(int i=2;i<sqrt(x);i+=(i==2?1:2))
{if(x%i==0){k=1;break;}}
if(k==0){cout<<"It is a prime word."<<endl;}
else cout<<"It is not a prime word."<<endl;}
return 0;
}
請問哪裡錯
判別某數是否為質數
=> 判別小於等於根號某數的質數是否為其因數
你少了一個等號
若有幫助到還請幫我留個言喔~~~
謝謝
http://ntnuee40475032h.pixnet.net/blog
#include <bits/stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
string a;
while(cin>>a)
{int c=a.size(),x=0;
for(int i=0;i<c;i++)
{if(a[i]>=97){x+=a[i]-96;}
else {x+=a[i]-38; }}
int k=0;
for(int i=2;i<sqrt(x);i+=(i==2?1:2))
{if(x%i==0){k=1;break;}}
if(k==0){cout<<"It is a prime word."<<endl;}
else cout<<"It is not a prime word."<<endl;}
return 0;
}
請問哪裡錯
判別某數是否為質數
=> 判別小於等於根號某數的質數是否為其因數
你少了一個等號
若有幫助到還請幫我留個言喔~~~
謝謝
http://ntnuee40475032h.pixnet.net/blog
感謝!!了解