✔ 最佳答案
//Power by Visual Studio 2005
#include<iostream>
#include<cstdlib>
#include<cmath>
using namespace std;
bool isPrime(double number)
{
bool retBoolean=true;
for(int i=2;i<=(int)sqrt(number);i++)
if(((int)number%i)==0)
{
retBoolean=false;
break;
}
return retBoolean;
}
int main(int argc, char** argv)
{
//==========START==========//
int A[10][10],number=2,id,temp,a,b,c,d,e,f,g,h;
for(int i=0;i<10;i++)
{
for(int j=0;j<10;j++)
{
while(!isPrime(number))
number++;
A[i][j]=number++;
}
}
cout<<"Input 8 bits ID: ",cin>>id,temp=id;
a=temp/(int)pow(10.0, 7.0),temp%=(int)pow(10.0, 7.0);
b=temp/(int)pow(10.0, 6.0),temp%=(int)pow(10.0, 6.0);
c=temp/(int)pow(10.0, 5.0),temp%=(int)pow(10.0, 5.0);
d=temp/(int)pow(10.0, 4.0),temp%=(int)pow(10.0, 4.0);
e=temp/(int)pow(10.0, 3.0),temp%=(int)pow(10.0, 3.0);
f=temp/(int)pow(10.0, 2.0),temp%=(int)pow(10.0, 2.0);
g=temp/(int)pow(10.0, 1.0),temp%=(int)pow(10.0, 1.0);
h=temp;
cout<<"A["<<a<<"]["<<b<<"]= "<<A[a][b]<<endl;
cout<<"A["<<c<<"]["<<d<<"]= "<<A[c][d]<<endl;
cout<<"A["<<e<<"]["<<f<<"]= "<<A[e][f]<<endl;
cout<<"A["<<g<<"]["<<h<<"]= "<<A[g][h]<<endl;
//==========END==========//
system("PAUSE");
return EXIT_SUCCESS;
}
2007-06-06 17:50:36 補充:
當然可以放質數表
2007-06-07 16:42:06 補充:
=質數表=
for(int i=0;i<10;i++)
{
for(int j=0;j<10;j++)
{
cout<<" "<<setw(3)<<A[i][j];
}
cout<<endl;
}
2007-06-08 10:35:56 補充:
輸入一個 8 位數的數值,每個數之間不可有空格。
2007-06-09 16:39:19 補充:
奇摩的補充內容有限制字數,根本無法放那麼多程式碼,所以你當初一開始提問題時,就應該寫清楚問題。