countdown

hi
Ich wollte unter c/c++ ein einfaches prog. schreiben das 10sec herunterzählt und dann das Wort "Null" ausgiebt.

hoffentlich kann mir wer helfen. :rolleyes:
 
Is ja gar net so einfach wie ich gedacht hatte :rolleyes:

Aber hier :D
Code:
//by Raptor
#include <iostream.h>
#include <ctime>

using namespace std;

int main()
{
	long now,end,tmp;
	
	time(&now);

	end=now+10;
	tmp=now;

	
	for(;now<=end;time(&tmp))
	{
		if(now!=tmp)
		{
		
			cout << end-now << endl;


			now=tmp;
		}
	}

cout << "null" << endl; 

return 0;

}

MfG

Raptor
 
Hier nochmal ganz einfach in c mit der Funktion sleep():

Code:
#include <stdio.h>

int main()
{
        int count;

        for(count=10; count>=1; count--)
                sleep(1);

        printf("NULL\n");

        return 0;
}
 
Ne sehr simple Lösung von mir.

Code:
#include <iostream.h>
#include <conio.h>
#include <dos.h>

int main()


{
int x = 10;

while (x > 0)
{
 cout << "Countdown : 00:" << x;
 sleep(1);
 x = x - 1;
 clrscr();
}

cout << "\n                                  Null !";

getch();

return 0;
}
 
Öhm, @eins über mir:
das war doch das gleiche wie oben schon mal, nur halt die längere Schreibweise mit nem clear screendazwischen.
 
Zurück
Oben