Hello surfersss,
Some observations before I get into testing the program.
One thing you will find when writing code is to be consistent with what you do. With the header files I like to do this:
1 2 3 4 5 6 7 8
|
#include<iostream>
#include<cstring>
#include <vector>
#include<cstdlib>
#include <cmath>
using namespace std; // <--- best not to use.
|
Order may not make any difference, but being consistent does help you to remember which header files you need. Normally "cstring" would just be "string". "stdlib.h" id a 50/50 when it comes to including this in a program. Some will say put it in if you think you will need it. And others, like me, will say that it is included somewhere in the "iostream" file.
The "stdio.h" file should be "cstdio" if you use it, but the "iostream" covers this file, so it is not needed.
The first three lines I consider the standard includes, although I include "iomanip" these days, the last two I consider the extras.
The variables "T", "M" and "K". First they should be lowercase letters for a regular variable. The capital letters make me think that they are defined as a constant variable. Also just because "T,M and K" are used in the instructions does not mean that you
have to use them. Give them a better name that describes what the variable is or does. This will help you in the future.
When it comes to writing a line like:
void segmentedsieve() {
. Although it is OK it works better as:
1 2 3
|
void segmentedsieve()
{
}
|
This way the {}s line up in the same column. Not only is it easier to read, but it is easier to find the matching brace when they are in the same column. Either way you choose to deal with the {}s be consistent through out the whole program.
I also noticed an extra blank line before some of the closing braces. It is OK, but not needed.
I offer this to help you in the future.
I will see how the program runs shortly.
Hope that helps,
Andy