First ident your code well
Code:
#include <iostream>
#include <cstdlib> //for atoi(), rand() and srand()
#include <ctime> //for time() and stuff
#include <cstring> //for strlen()
#include <windows> //-> you don't need this for sure!and it's windows.h
using namespace std;
//a function which receives a pointer to char, which is typically, a C-style string
//an array of chars, and returns a boolean value - true or false...
bool isnum(const char * str) {
//this is the var you're going to return, lets assume the string is indeed a number
bool r =true;
//now loop the string - if you find a char that is not a number return false
for (int i =0; i< strlen(str);i++) {
if (str[i] < '0' || str[i] > '9')
r =false;
}
return r;
}
A small but important recomendation !
for (int i =0; i< strlen(str);i++) {
Code:
//this does N^2 iterations
for(int i=0;i<strlen(str);i++)
//this does 2*N iterations
int len = strlen(str);
for(int i=0;i<len;i++)
//this does N iterations
for(int i=0;str[i];i++) //str[i] != 0
The rest of the code... for me some other time