473,405 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

problem with counter

Hello,

i got following Job:
Write a programm that shows the letters a - z. The lettes should be
act in some millisecounds. Start with 100 millisecounds and every loop
the millisecounds show be rise of 10 percent (such as the secound loop
110, the third 121...)

First Time i thougt this.

execute the loop until the actual time is bigger then the pause (100
millisecounds).

But it doesent work.

I hope you can help me

Regards

Sebastian

=== German Version ===

Hallo,

ich habe folgende Aufgabe bekommen.

Schreibe ein programm das die Zahlen 1 bis 100 ausgibt. Die Zahlen
sollen nacheinander erscheinen aber in unterschiedlichen
Zeitabständen. Beginne mit 100 Ms und steigere in jeder runde die
Millisekunden um 10 Prozent.
Wie soll ich das in der console machen? ich kann mir mit clock die
aktuelle uhrzeit holen, "Startzeit" messen- Schleife solange
ausführen bis "aktuelle Zeit" - "Startzeit" >= "Pause". Das ist ja
soweit klar, aber wie soll ich das programmieren?

Ich blicke da nicth so durch.

Bitte erklärt es mir

Gruß

Sebastian

Mar 19 '07 #1
4 1372
Test3456 wrote:
Hello,

i got following Job:
Write a programm that shows the letters a - z. The lettes should be
act in some millisecounds. Start with 100 millisecounds and every loop
the millisecounds show be rise of 10 percent (such as the secound loop
110, the third 121...)
First Time i thougt this.

execute the loop until the actual time is bigger then the pause (100
millisecounds).
AFAIK, there is no platform-independent way of doing this. Under Windows
look up the Sleep (DWORD Milliseconds) function.

Regards,
Stuart
Mar 19 '07 #2
On Mon, 19 Mar 2007 09:01:57 -0700, Test3456 wrote:
Hello,

i got following Job:
Write a programm that shows the letters a - z. The lettes should be
act in some millisecounds. Start with 100 millisecounds and every loop
the millisecounds show be rise of 10 percent (such as the secound loop
110, the third 121...)

First Time i thougt this.

execute the loop until the actual time is bigger then the pause (100
millisecounds).

But it doesent work.
That doesn't really help anyone solve your problem. Post some (preferably
compilable) code showing what you have tried so far, and explain what you
mean by "doesn't work".

[...]

--
Lionel B
Mar 19 '07 #3
On 19 Mrz., 17:14, Lionel B <m...@privacy.netwrote:
On Mon, 19 Mar 2007 09:01:57 -0700, Test3456 wrote:
Hello,
i got following Job:
Write a programm that shows the letters a - z. The lettes should be
act in some millisecounds. Start with 100 millisecounds and every loop
the millisecounds show be rise of 10 percent (such as the secound loop
110, the third 121...)
First Time i thougt this.
execute the loop until the actual time is bigger then the pause (100
millisecounds).
But it doesent work.

That doesn't really help anyone solve your problem. Post some (preferably
compilable) code showing what you have tried so far, and explain what you
mean by "doesn't work".

[...]

--
Lionel B
#include <iostream>
#include <ctime>

const unsigned short count_numbers = 100;

int main()
{
std::wcout << L"Wellcome to Clock-Counter V0.1" << std::endl;

clock_t time_start = clock();

for (unsigned short number = 1; number <= count_numbers; ++number)
{
while ((clock() - time_start) (number * 10)); // Jetzt
wird gewartet, bis die
//
Differenz von vorher und jetzt
// gleich
(number * 10) ist ...
// TODO:
Gewünschte Zeit einsetzen.

std::wcout << number << std::endl; // Zahl
ausgeben ...
}

return 0;
}

This is my code, which i have at the moment, but it doesent seam to
work. I hope you dont understand my explanation right.

The First Number should be appear 1 secound or 1000 ms. but i dont
know why this code doesnt work.

I tryed to solve the problem 4 hours but i cannot find this error :-(

Mar 19 '07 #4
>>On Mon, 19 Mar 2007 09:01:57 -0700, Test3456 wrote:
>>>i got following Job:
Write a programm that shows the letters a - z. The lettes should be
act in some millisecounds. Start with 100 millisecounds and every loop
the millisecounds show be rise of 10 percent (such as the secound loop
110, the third 121...)
>>>First Time i thougt this.
>>>execute the loop until the actual time is bigger then the pause (100
millisecounds).
>>>But it doesent work.
Test3456 wrote:
#include <iostream>
#include <ctime>

const unsigned short count_numbers = 100;

int main()
{
std::wcout << L"Wellcome to Clock-Counter V0.1" << std::endl;

clock_t time_start = clock();
You only take the start time once. I think you actually want to take the
start time each time you're going to wait for the next number.
for (unsigned short number = 1; number <= count_numbers; ++number)
{
while ((clock() - time_start) (number * 10));
This condition will never be true since the time taken at the call of
clock will be very close to time_start, so that clock() - time_start is
almost always smaller than number * 10. Thus the while loop will exit at
the first iteration (so that it won't "eat away" any time at all).
std::wcout << number << std::endl;
}

return 0;
}
This is my code, which i have at the moment, but it doesent seam to
work. I hope you dont understand my explanation right.

The First Number should be appear 1 secound or 1000 ms. but i dont
know why this code doesnt work.

I tryed to solve the problem 4 hours but i cannot find this error :-(
You should inflate the code so that you can run it through a debugger
(by inflating I mean that you should expand the while loop so that you
can see how many times it runs). Cutting down the code to a point where
you have solved the problem with the minimum amount of code will get you
to a point where you spend the maximum amount of time debugging.

Regards,
Stuart
Mar 19 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Andrew Baker | last post by:
What is the best way to lock an individual row in the following scenerio: --TODO - LOCK THIS ROW -- Return the next id SELECT next_id INTO next_id_out FROM owner.my_id_table WHERE app_id =...
10
by: Cam | last post by:
Hi all, The code below is a practical exercise and works well running in the debug environment but fails when being compiled for a release build. I believe this is because the debug environment...
2
by: Lloyd Dupont | last post by:
where is the webshared directory information ? I create a Webapplication called Counter in C:\IntePub\wwwroot\Counter the Counter directory was webshared under the name 'Counter'. I copied the...
14
by: Jim Michaels | last post by:
mysql_query("START TRANSACTION", $link2); $q2=mysql_query("SELECT pictures.pid AS pid FROM pictures,counter WHERE pictures.pid>counter.pid LIMIT 1", $link2); if ($row2=mysql_fetch_assoc($q2)) {...
8
by: | last post by:
I have a simple structure for example purposes I add to an array list public structure MyStruct dim counter as integer end structure dim mylist as ArrayList dim x as New MyStruct ...
17
by: Jonathan Pritchard | last post by:
I know this is a simple problem, but I've just included this in the title because it explains what my program tries to do. The following does not work, it for someone reason does not want to...
6
by: caine | last post by:
I have a clickable calendar, which user can select the day that they want to view the news linking to. My calendar has the clickable event day, but once the user click it, the day selected could...
4
by: Tigger2000 | last post by:
I keep getting an error when trying to compile this for Java prog class, below is the instructions for the assignment and my code. Loop Assignment Write, compile, and run a Java program that...
19
by: rmr531 | last post by:
First of all I am very new to c++ so please bear with me. I am trying to create a program that keeps an inventory of items. I am trying to use a struct to store a product name, purchase price,...
2
by: Zerofury | last post by:
Okay this is what i'm attempting to do. I have to modify this program that i wrote so that it allows the user to list items by alpha as an option on the main menu. Here is my problem. If i sort the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.