Code running error

Level 1: Small perfect numbers Begin by writing a program that prints perfect numbers (those with a badness of 0). Separate the output of each number by a single space. Read the limiting value as a command line argument. For example, quitegood 100 should print 6 28. For this level, you can assume that the limiting value will not exceed 10,000.
Level 2: Small near-perfect numbers Extend the program so that the badness limit can be specified as a second command line argument. For example,
quitegood 100 3 should print 2 3 4 6 8 10 16 18 20 28 32 64.
Level 3: Large numbers Extend the program so that it will work efficiently for values up to at least 1,000,000. For example, quitegood 1000000. it should print 2 4 6 8 16 28 32 64 128 256 496 512 1024 2048 4096 8128 8192 16384 32768 65536 131072
262144 524288.
Level 4: Convert either way Extend the program so that a negative badness value causes the program to output a count of the quite good numbers rather than the numbers themselves. For example, quitegood 1000000 -1 should print 23 because there are 23 numbers less than 1,000,000 with a badness no more than 1.

#include <iostream>
#include <math.h>
#include <string>
using namespace std;
bool checkFactor(int ouFactor, int ourNumber) {
if (ourNumber % ouFactor == 0) {
return true;
} else {
return false;
}
}
int badnessValueCalc(int ourNumbernum) {
int ourTotal = 1;
for (int ouFactor = 2; ouFactor < ourNumbernum; ouFactor++) {
if (checkFactor(ouFactor, ourNumbernum)) {
ourTotal += ouFactor;
}
}
int badnessValue = ourNumbernum - ourTotal;
return abs(badnessValue);
}
void display(int n, int b) {
int count = 0;
for (int k = 2; k < n; k++) {
int bValue = badnessValueCalc(k);
if (b < 0) {
if (bValue <= abs(b))
count++;
} else if (bValue <= (b)) {
cout << k << " ";
}
}
if (b < 0)
cout << count << " ";
cout << endl;
}
int main(int argc, char *argvt[1]) {
int n = 100;
int b = 0;
display(n, b);
cout << "\n\n";}

This isn't windows programming - its just c++. You'd be better off re-posting in the General C++ forum.

Also, when posting use code tags around the code so that it's readable

[code]
//code goes here
[/code]


Topic archived. No new replies allowed.