c++运行错误
#include<bits/stdc++.h>
using namespace std;
int put[100];
bool ss(int a)
{
for(int i=2;i*i<=a;i++)
{
if(a%i==0)
{
return false;
}
}
return true;
}
int main()
{
srand(int(time(0)));
long long p,q,e,n,sum=0,xjh,pd,d;
while(sum>e*100)
{
xjh=rand()*100;
if(xjh>1000||ss(xjh)==true)
{
p=xjh;
break;
}
sum++;
}
sum=0;
pd=rand();
while(sum>pd*100)
{
xjh=rand()*100;
if(xjh>1000||ss(xjh)==true)
{
q=xjh;
break;
}
sum++;
} //生成两个互质的随机数p,q
n=p*q;
while(true)
{
e=rand();
if(ss(e)==true)
{
break;
}
}
d=(e-1)%((p-1)*(q-1));
cin>>put[100];
int i=0;
while(put[i]!=0)
{
cout<<put[i]*d;
i++;
}
return 0;
}
求大神答疑
程序至少有一个错
cin>>put[100]; //下标溢出
你的int put[100];中的put只能用put[0]~put[99],这个是基础的了
热门标签: