Prime numbers program

后端 未结 14 1655
无人及你
无人及你 2021-01-07 00:27

I\'m currently trying out some questions just to practice my programming skills. ( Not taking it in school or anything yet, self taught ) I came across this problem which re

14条回答
  •  清歌不尽
    2021-01-07 01:05

    #include 
    #include 
    #include 
    #include 
    
    using namespace std;
    
    int main()
    {
    ifstream trial;
    trial.open("C:\\Users\\User\\Documents\\trial.txt");
    int prime, e;
    trial>>prime;
    ofstream write; 
    write.open("C:\\Users\\User\\Documents\\answer.txt");
    int num[10000], currentPrime, c, primePrint;
    bool check;
    currentPrime=0;
    num[currentPrime] = 2;
    currentPrime=1;
    
    for(int currentInt=2; currentInt<=1000000; currentInt++) 
    {check = false; 
    for( int arrayPrime=0; arrayPrime

    This is the finalized version base on my original code. It works perfectly and if you want to increase the range of prime numbers simply increase the array number. Thanks for the help =)

提交回复
热议问题