Created
January 4, 2012 10:58
-
-
Save thetekst/1559564 to your computer and use it in GitHub Desktop.
TimerOnC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Algorithm | |
Просим ввести число мин в переменную minutes | |
запускаем функцию таймера. | |
сравниваем ее в цикле с переменной minutes: minutes<=timer | |
Если условие истинно, то повторяем цикл while() | |
Если условие ложно: выводим сообщение и обнуляем minutes | |
*/ | |
#include <stdio.h> | |
#include <time.h> | |
/* | |
#include <windows.h> | |
#include <conio.h> | |
#include <dos.h> | |
*/ | |
//#define MINUTES 2000 | |
void main(void) | |
{ | |
time_t timer; | |
int minutes=2000; | |
// printf("Input time in minutes: "); | |
// scanf("%d", minutes); | |
do | |
{ | |
sleep(1000); | |
printf("Осталось %ld min\n", minutes-timer); | |
} | |
while(minutes<timer); | |
printf("Время вышло"); | |
} | |
//----------------------------------------------------- | |
/* | |
#include <stdio.h> | |
#include <time.h> | |
int main(void) | |
{ | |
const time_t timer = time(NULL); | |
printf("%s\n", ctime(&timer)); | |
return 0; | |
} | |
*/ | |
//----------------------------------------------------- | |
/* | |
#include <windows.h>//Для Sleep() | |
using namespace std; | |
int main() | |
{ | |
for( int i = 0; i < 1000; i++ ) | |
{ | |
for( int j = 0; j < 60; j++ )//Цикл выполнится 60 секунд | |
{ | |
Sleep(1000);//1 секунда | |
} | |
//Вызов функции | |
} | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment