Click here to Skip to main content
Licence 
First Posted 15 Aug 2003
Views 48,320
Bookmarked 12 times

Experience: mental prac

By | 15 Aug 2003 | Article
This program tests you on math problems to improve your thinking.

Sample Image - sc2.png

Introduction

From my experience, I have realized that experience is the best teacher. By doing something repeatedly, you can improve your skills. The way you think can be altered and changed for the better.

By thinking past the normal average person on a daily basis, your thinking process can improve towards above normal. The ability to think faster and more logically is at our fingertips.

I have made a program that test you on math problems not ususally done on a normal basis. It will test you on 5 random problems and record you stats.

In this program, I really didn't post it up to show coding techniques or anything like that. I posted this because I wanted to show how experience would always have the advantage over studying books.

But on a coding level :

My program random choice of math problems relies on time.

I've made this source/header file so that i could have a little library of my own functions.

 

/*tools.cpp                                                          */
/*simple tools here and there that i've made to use in other projects*/
/*just things i find that i could use later                          */

/*include files */
#include "tools.h"
#include "stdafx.h"

/*this function returns a randomized number between    */
/*1 and 20 with relations to the systems clock (milli) */
double low_rand()
{
 /*initalize rand (double)*/
 double rand = 0.0;

 /*_timeb struct*/
 struct _timeb time;

 /*fills the timeb struct with data (current time)*/
 _ftime(&time);
 
 /*change whole number into an decimal form*/
 /*example: 989 to .989                    */
 rand = (time.millitm * ((double).001));

 /*times rand by 100                       */
 /*example: .989 to 98.8                   */
 rand = (rand * 100);

 /*divides rand by 5                       */
 /*example: 98.9 to 19.78                  */
 rand = (rand / 5);

 /*returns rand with is a number between 1 and 20*/
 return rand;
}

/*this function returns a randomized number between     */
/*1 and 1000 with relations to the systems clock (milli)*/
int high_rand()
{
 /*_timeb struct*/
 struct _timeb time;
 /*fills the timeb struct with data (current time)*/
 _ftime(&time);

 /*returns the time (milli) as a random number*/
 return time.millitm;
}

/*retrieves the current time from the system          */
void timec(_stime &stime)
{
 /*struct for system time*/
   SYSTEMTIME time;

   /*retrieves the local time*/
   GetLocalTime(& time);

   /*loads the _stime struct with the current time*/
   stime.hour = time.wHour;
   stime.min = time.wMinute;
   stime.sec = time.wSecond;
   stime.milli = time.wMilliseconds;
}

/*the input is a certain time and the output is        */
/*the difference between that time and the current time*/
/*implemented in a stop watch manner                   */
_stime timer(_stime &stime)
{
 /*copy the _stime given to the function to avoid mistakes between transfer of information*/
 _stime calc_time = stime;

 /*struct for system time*/
 SYSTEMTIME time;
 /*retrieves the local time*/
 GetLocalTime(& time);

 /*calculate the difference between current time and time given*/
 /*calculate hour*/
 if(calc_time.hour >= time.wHour)
 {
  calc_time.hour = calc_time.hour - time.wHour;
 }
 else
 {
  calc_time.hour = time.wHour - calc_time.hour;
 }

 /*calculate min*/
 if(calc_time.min >= time.wMinute)
 {
  calc_time.min = calc_time.min - time.wMinute;
 }
 else
 {
  calc_time.min = time.wMinute - calc_time.min;
 }

 /*calculate sec*/
 if(calc_time.sec >= time.wSecond)
 {
  calc_time.sec = calc_time.sec - time.wSecond;
 }
 else
 {
  calc_time.sec = time.wSecond - calc_time.sec;
 }

 /*calculate milli*/
 if(calc_time.milli >= time.wMilliseconds)
 {
  calc_time.milli = calc_time.milli - time.wMilliseconds;
 }
 else
 {
  calc_time.milli = time.wMilliseconds - calc_time.milli;
 }


 /*return the difference between the current time and the given time*/
 return (calc_time);
}

/*beg to end*/
int btoe(char *filename)
{
 int lines = 0;
 char search[255];

 if(filename != NULL)
 {
  ifstream ifile(filename);

  do
  {
   ifile.getline(search, 255);
   ++lines;
  }while(ifile.eof() == 0);

  ifile.close();
 }
 else
 {
  lines = -1;
 }

 return lines;
}

/*beg to space*/
int btos(char *filename)
{
 int lines = 0;
 char search[255];
 bool reached_space = false;

 if(filename != NULL)
 {
  ifstream ifile(filename);

  do
  {
   ifile.getline(search, 255);
   ++lines;

   if(ifile.eof() == 1)
   {
    reached_space = true;
   }

  }while(true != reached_space);

  ifile.close();

 }
 else
 {
  lines = -1;
 }

 return lines;
}

/*search file for a sentence*/
int sfile(char *filename, char *sentence)
{
 int lines = 0;
 char search[255];
 bool searching = true;

 if(filename != NULL)
 {
  ifstream ifile(filename);

  do
  {
   ifile.getline(search, 255);
   ++lines;

   if(ifile.eof() == 1)
   {
    searching = false;
    lines = -1;
   }

  }while(false != searching);

  ifile.close();
 }
 else
 {
  lines = -1;
 }

 return lines;
}

/*gets the actual length of a c string (array)*/
int str_length(char str[], int length)
{
 int str_size = 0;

 for(int x = 0; x < length; ++x)
 {
  if(str[x] != 0)
  {
   ++str_size;
  }
  else
  {
   break;
  }
 }

 return str_size;
}

//////////////////////////////////////////////////////////////

the functions in this source/header file were used to manipulate the time and to do basic work on time related functions.

the code above is probably the most important part of the whole program, because it handles the time which is somewhat widely used.

 

--ice911

(thanks for checking out my article)

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

ice911

Web Developer

United States United States

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralGreat one! Pinmembercristitomi6:55 16 Mar '07  
GeneralGRRRR....... Pinmembersnyp6:06 16 Aug '03  
GeneralRe: GRRRR....... PinmemberDaniel Turini6:09 16 Aug '03  
GeneralLOL Pinmemberdog_spawn9:56 16 Aug '03  
GeneralRe: LOL Pinmemberice91111:18 16 Aug '03  
GeneralRe: GRRRR....... Pinmemberice9119:41 16 Aug '03  
GeneralRe: GRRRR....... Pinmemberdog_spawn9:54 16 Aug '03  
GeneralIrony begins Pinmemberdog_spawn3:00 16 Aug '03  
GeneralRe: Irony begins Pinmemberice9119:47 16 Aug '03  
GeneralCryptic replies on CP reach a new level Pinmemberdog_spawn9:53 16 Aug '03  
GeneralRe: Irony begins PinmemberJohn R. Shaw11:29 16 Aug '03  
GeneralRe: Irony begins Pinmemberice91120:58 16 Aug '03  
GeneralRe: Irony begins PinsussMrNDIS4:43 17 Aug '03  
GeneralRe: Irony begins PinmemberAmer Gerzic10:10 17 Aug '03  
GeneralRe: Irony begins Pinmemberice91111:28 17 Aug '03  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 16 Aug 2003
Article Copyright 2003 by ice911
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid