Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
ThursdayTG committed Feb 9, 2022
1 parent b610e30 commit 1d7b668
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 49 deletions.
16 changes: 16 additions & 0 deletions headers/output.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef HEADERS_OUTPUT
#define HEADERS_OUTPUT

#include <string>


void printLabel(int, int);
void printSeparators(int, int, std::string);

void printHeader(int, int, int);
void printFooter(int, int, int);


#endif


62 changes: 13 additions & 49 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <cmath>

#include "../headers/genericFunctions.hpp"
#include "../headers/output.hpp"


using std::cout;
Expand Down Expand Up @@ -45,6 +46,15 @@ int main()
}


//=== separators - no idea where to put this rn, lol
int amountSeparators = amountColumns * 32;
if (upperBound >= 1e+006)
{
amountSeparators *= 1.25;
}
amountSeparators += 4;


//=== output of corrected user input
clearScreen();
cout << " \n"
Expand All @@ -54,39 +64,7 @@ int main()


//=== output - header ===
int amountSeparators = 0;

cout << " \n"
<< " \n prime numbers in given range: \n"
<< " \n";

cout << " ";
for (int col = 0; col < amountColumns; col++)
{
cout << "++++++[ number ";
if (upperBound >= 1e+006)
{
cout << "\t ";
}
cout << "| difference ]++";
}

amountSeparators = amountColumns * 32;
if (upperBound >= 1e+006)
{
amountSeparators *= 1.25;
}
amountSeparators += 4;

cout << "++++ \n ";
for (int sep = 0; sep < amountSeparators; sep++)
{
cout << "-";
}
cout << " \n"
<< " \n"
<< " \n"
<< " ";
header(amountColumns, upperBound);


//=== primary function - finding prime numbers in given range
Expand Down Expand Up @@ -156,21 +134,7 @@ int main()
//=== output - footer
cout << " \n\n ";

for (int sep = 0; sep < amountSeparators; sep++)
{
cout << "-";
}
cout << " \n ";

for (int col = 0; col < amountColumns; col++)
{
cout << "++++++[ number ";
if (upperBound >= 1e+006)
{
cout << "\t ";
}
cout << "| difference ]++";
}
//tableLabelling(amountColumns, upperBound);

cout
<< "++++"
Expand All @@ -189,7 +153,7 @@ int main()
<< amountPrimes / (upperBound - lowerBound + 1) * 100 << "%"
<< " \n\n ";

for (int sep = 0; sep < amountSeparators / 2; sep++)
for(int sep = 0; sep < amountSeparators / 2; sep++)
{
cout << "- ";
}
Expand Down
74 changes: 74 additions & 0 deletions src/output.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#include <iostream>
#include <string>

#include "../headers/genericFunctions.hpp"


using std::cout;
using std::string;




void printLabel(int amountColumns, int upperBound)
{
for (int col = 0; col < amountColumns; col++)
{
cout << "++++++[ number ";
if (upperBound >= 1e+006)
{
cout << "\t ";
}
cout << "| difference ]++";
}
}


void printSeparators(int amountSeparators, int amountColumns, string separator)
{
for (int i = 0; i < amountSeparators; i++)
{
cout << separator;
}
cout << " \n ";
}

//


void printHeader(int amountColumns, int amountSeparators, int upperBound)
{


cout
<< " \n"
<< " \n prime numbers in given range: \n"
<< " \n"
<< " ";

printLabel(amountColumns, upperBound);
cout << "++++ \n ";

printSeparators(amountSeparators, amountColumns, "");

cout
<< " \n"
<< " \n"
<< " \n"
<< " ";
}


void printFooter(int amountColumns, int amountSeparators, int upperBound)
{
cout
<< " \n"
<< " \n"
<< " ";

printSeparators(amountSeparators, amountColumns, "");

printLabel(amountColumns, upperBound);

printSeparators(amountSeparators/2, amountColumns, "");
}

0 comments on commit 1d7b668

Please sign in to comment.