I am writing a program just for fun, that you have to know the word "pi" in order to be able to close the program while it is running. I got the code running but whenever I enter a number of loops too high, the program just quits after a certain point! Can you tell me what I am doing wrong?
#include <iostream>
#include <windows.h>
#include <winable.h>
#include <stdio.h>
#include <string.h>
usingnamespace std;
int main(void) {
int x;
int y;
int z;
int t;
int loop;
int beeps;
int length;
loop = 100;
string stringOne;
cout <<"Hello, the magic word is pi";
Sleep(1000);
system("CLS");
cout <<"\nHow many loops would you like? (do not recommend > 100, 750 is max) : ";
cin >> y;
cout <<"\nWhat would you like the beep to be? : ";
cin >> z;
if (z < 200){
t = z + 100;
}
else {
t = 100;
}
while (y > 750) {
y = y - 700;}
while (z > 99999){
z = z / 100; }
cout << "\nWhat is the magic word? :";
cin >> stringOne;
beeps = y;
cout << "loops left : ";
for (x = 0; x < y; x++){
if (stringOne != "pi")
{
BlockInput (true);
}
beeps--;
system("CLS");
cout << " " <<beeps;
if (beeps == 0){
Beep( 2000,325);
}
Beep(z+loop,t);
if (loop > 5)
{
Sleep(loop);
loop = loop - 2;
}
if (t > 10)
{
t = t - 2;
}
Beep(z+loop,t);
if (loop < 5)
{
Sleep(loop);
loop = loop - 2;
}
if (t > 10)
{
t = t - 2;
}
}
return 0;
}
"This, I simply don't understand."
Well the point of this is to pause only if loop is greater than 5, and if it is then you shorten the pause by 2, it makes the beeps more frequent; and I really don't need it. I am really not sure what you mean when you say "to their maximum allowed values, could you expand that thought?
Well the point of this is to pause only if loop is greater than 5, and if it is then you shorten the pause by 2, it makes the beeps more frequent; and I really don't need it.
Wouldn't it make more sense to use something more like Sleep((loop*loop+loop)/2) (note: this formula does almost the same as the loop, except the -2 is a -1)?
I am really not sure what you mean when you say "to their maximum allowed values, could you expand that thought?