首页 > 电脑

c++运行错误

更新时间2019-05-26 15:33:53

#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],这个是基础的了

上一篇:求一个C++的单机音乐播放器源代码

下一篇:局域网内两台WIN7笔记本都已连接WIFI,如何通过有线让副机直接访问主机硬盘和打印机?