當前位置:首頁 » 編程語言 » c語言新年倒計時程序
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

c語言新年倒計時程序

發布時間: 2022-12-30 20:28:32

㈠ [求]c語言倒計時程序

編譯器: Default compiler
執行 gcc.exe...
gcc.exe "C:\Documents and Settings\Administrator\桌面\未命名2.c" -o "C:\Documents and Settings\Administrator\桌面\未命名2.exe" -ansi -traditional-cpp -w -g3 -fmessage-length=0 -I"C:\Program Files\DEV-CPP\include" -L"C:\Program Files\DEV-CPP\Lib" -g3 -fmessage-length=0
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/cc8Ueaaa.o(.text+0x4f): In function `main':
C:/Documents and Settings/Administrator/桌面/未命名2.c:10: undefined reference to `clrscr'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/cc8Ueaaa.o(.text+0xca):C:/Documents and Settings/Administrator/桌面/未命名2.c:17: undefined reference to `clrscr'
collect2: ld returned 1 exit status

執行結束

pengming501 為什麼編譯器提示有2處錯誤呢??

㈡ 求倒計時的程序 C語言的,帶有按鍵功能的

給你一個以秒計的代碼
設定一個變數存儲你的倒計時數
int m_time;
scanf("%d",&m_time);

下面的代碼放到你界面的按鍵的代碼區
int counter=m_time;
DWORD start=GetTickCount()/1000;
int m_num=0;//賦值1的目的是讓下面的循環可以開始執行。
while(counter-m_num)
{
int m_num=GetTickCount()/1000-start;
printf("倒計時:%d秒",counter-m_num);
}

大功告成

詳細解答,望閣下採納

㈢ c語言倒計時怎麼編

定位要倒計時的坐標!然後再需要倒計時的地方添加gotoxy(所定位的坐標),當然這只是十以下的倒計時,超過了十則會清除不了十位數上的數字,要解決這個辦法就是輸出%2d

㈣ 如何在c語言程序中插入一個倒計時命令

#include <stdio.h>
int main()
{
printf("hello world");
for(int i=60;i>0;i--)
{
printf("%d",i);
Sleep(1000);
}
}

㈤ c語言 倒計時程序

對硬體的啊。

P2=0;
P1=display_code[display_data[i]];
P2=k;
k=k>>1;
不懂。

不過感覺問題不大。先把main里的i的上限從250改到216.
在display()里做3個判斷(可能會要做個全局變數,或者加個參數,記錄當前是多少。)
判斷是否是0,大於10,大於100
另外,站長團上有產品團購,便宜有保證

㈥ c語言倒計時程序設計:要求從鍵盤輸入倒計的時間分數和秒數,按「回車鍵」開始倒計,直到計時時間結束。

#include<stdio.h>
#include<stdlib.h>
#include<windows.h>

intmain()
{
intsec;
intmin;
printf("請輸入時間:分鍾和秒數 ");
scanf("%d%d",&min,&sec);
printf("按回車鍵開機計時 ");
getchar();
for(min;min>0;min--)
{
for(sec;sec>=0;sec--)
{
Sleep(1);
if(sec==0)
{
sec==60;
break;
}
}
}
printf("計時結束 ");

}

㈦ 倒計時器c語言源程序

#include <stdio.h>
#include <time.h>

struct Clock
{
int sec,min,hour;
void tick();
void show();
void run();
void set(int h,int m,int s);
};

void Clock::tick()
{
long t=time(NULL);
while(t==time(NULL));
if(--sec<0){
sec=59;
if(--min<0){
min=59;
--hour;
}
}
}

void Clock::show()
{
printf("\r");
if(hour<10)
printf("0");
printf("%d:",hour);
if(min<10)
printf("0");
printf("%d:",min);
if(sec<10)
printf("0");
printf("%d",sec);
}

void Clock::run()
{
while(sec!=0||min!=0||hour!=0){
tick();
show();
}
}

void Clock::set(int h,int m,int s)
{
hour=h;
min=m;
sec=s;
}

int main()
{
int s,m,h;
printf("請輸入時間(hhmmss):");
scanf("%d%d%d",&h,&m,&s);
Clock c;
c.set(h,m,s);
c.run();
printf("time is over!!!\a");
}

㈧ 這么用C語言做倒計時器

tdio.h>
#include <conio.h>
#include <windows.h>
#include <stdlib.h>
struct tm //定義時間結構體,包括時分秒和10毫秒
{
int hours,minutes,seconds;
int hscd;
}time,tmp,total; //time用以計時顯示,tmp用以存儲上一階段時間,total記總時間
int cnt;

FILE* fout;
//每次調用update函數,相當於時間過了10ms
void update(struct tm *t)
{

(*t).hscd++; //10ms單位時間加1
cnt++;
if ((*t).hscd==100) //計時滿1s,進位
{
(*t).hscd=0;
(*t).seconds++;
}
if ((*t).seconds==60) //計時滿一分,進位
{
(*t).seconds=0;
(*t).minutes++;
}
if ((*t).minutes==60) //計時滿一小時,進位

{
(*t).minutes=0;
(*t).hours++;
}
if((*t).hours==24) (*t).hours=0;
//delay();
Sleep(10); //Sleep是windows提供的函數,作用是暫停程序,單位毫秒,所以此處暫停10ms
}
void display(struct tm *t)
{
//此處輸出計時結果,\r為回車不換行,既一直在同一行更新時間
printf("%d:",(*t).hours);
printf("%d:",(*t).minutes);
printf("%d:",(*t).seconds);
printf("%d\r",(*t).hscd);
//printf("Now, press 『e』 key to stop the clock…");
}
void time_init() //初始化時間
{
time.hours=time.minutes=time.seconds=time.hscd=0;
}
void get_total() //計算總時間
{
total.hscd = cnt % 100;
cnt /= 100;
total.seconds = cnt % 60;
cnt /= 60;
total.minutes = cnt % 60;
cnt /= 60;
total.hours = cnt;
}
int main()
{
char m;
time_init();
cnt = 0;
fout = fopen("timeout.txt","w");
printf("按回車鍵開始計時!\n");
while(1)
{
m = getch();
if(m != 『\r』) //讀入一個輸入,如果是回車,那麼跳出次循環
printf("輸入錯誤,僅能輸入回車鍵!\n");
else
break;
}
printf("已經開始計時,但是你可以按回車鍵以分段計時!\n");
while(1)
{
if(kbhit()) //此處檢查是否有鍵盤輸入
{
m=getch();
if(m == 『\r』) //如果等於回車,那麼計時結束,跳出循環
break;
else if(m == 『 『) //如果等於空格,顯示此次計時,初始化計時器
{
tmp = time; //記錄上一段計時器結果
fprintf(fout,"%d:%d:%d:%d\n",tmp.hours,tmp.minutes,tmp.seconds,tmp.hscd); //寫入文件
time_init();
printf("\n");
}
else
{
printf("輸入錯誤,僅支持輸入回車鍵或者空格鍵!\n");
}
}
update(&time); //更新計時器
display(&time); //顯示計時器時間
}
tmp = time; //輸出最後一次即使結果,寫入文件
fprintf(fout,"%d:%d:%d:%d\n",tmp.hours,tmp.minutes,tmp.seconds,tmp.hscd);
get_total(); //計算總的時間,顯示,並寫入文件
printf("\n總時間:%d:%d:%d:%d\n",total.hours,total.minutes,total.seconds,total.hscd);
fprintf(fout,"統計時間:%d:%d:%d:%d\n",total.hours,total.minutes,total.seconds,total.hscd);
fclose(fout);
printf("已經保存到當前目錄下的timeout.txt文件中按任意鍵結束!");
getch();

}
另外,站長團上有產品團購,便宜有保證

㈨ 89c51單片機c語言課程設計新年倒計時電腦時鍾的設計(4個數碼管,我急需程序)!!!

==========================
推薦一個電子技術導航網站你吧!------ 電子世家網址導航 。它分類收錄了很多優秀的電子技術網站,你可以去逛逛的;特別是它裡面的那些網站的論壇,有很多大蝦分享的資料,希望能對在日後從事電子技術的工作中有幫助啦
======================

㈩ 求個c語言小代碼,很簡單的倒計時程序


#include<stdio.h>
#include<windows.h>

intmain(void)
{
inta;
a=0;
boolup=true;
system("color0A");

while(true)
{
system("cls");

printf("%d a",a);
Sleep(100);
if(up)
{
a++;
}
if(!up)
{
a--;
}
if(a==0)
{
up=true;
}
if(a==100)
{
up=false;
}

}

return0;
}