Yuav Ua Li Cas Thiaj Ua Tau Cov Phiaj Xwm Nres Hauv Pascal

Cov txheej txheem:

Yuav Ua Li Cas Thiaj Ua Tau Cov Phiaj Xwm Nres Hauv Pascal
Yuav Ua Li Cas Thiaj Ua Tau Cov Phiaj Xwm Nres Hauv Pascal

Video: Yuav Ua Li Cas Thiaj Ua Tau Cov Phiaj Xwm Nres Hauv Pascal

Video: Yuav Ua Li Cas Thiaj Ua Tau Cov Phiaj Xwm Nres Hauv Pascal
Video: Tsis Muaj Peev Xwm Yuav Ua Li Cas 2024, Hlis ntuj nqeg
Anonim
Yuav ua li cas thiaj ua tau cov phiaj xwm nres hauv Pascal
Yuav ua li cas thiaj ua tau cov phiaj xwm nres hauv Pascal

Tsim nyog

PascalABC. NET lossis PascalTurbo ib puag ncig cov kev pab cuam

Cov Lus Qhia

Kauj ruam 1

Yog li, ua ntej, peb qhib qhov program. Cia peb tsim cov ntaub ntawv tshiab thiab hais kom meej cov plugins. Hauv qhov no, peb xav tau ib lub qauv rau kev ua haujlwm nrog cov nplig - CRT.

rau qhov no peb yuav sau:

siv

CRT;

Kauj ruam 2

Cia peb qhia cov lej sib txawv ntawm i, s, m - hloov pauv ntawm hom tiag.

var

i, s, m: Tiag;

Kauj ruam 3

Txhawm rau pib txoj haujlwm, sau:

pib

Thiab peb yuav qhia lub npe ntawm lub qhov rai console:

SetWindowTitle ('Stopwatch');

Kauj ruam 4

Cov txheej txheem TextColor muab cov xim rau cov ntawv nyeem, thiab Daim Ntawv Sau Sau qhia cov lus rau hauv lub vijtsam:

TextColor (Lub Teeb Nruab Nrab);

WriteLn ('Nias Sau kom pib stopwatch');

WriteLn ('Nias ntxiv kom tsum tsis txhob');

Sau ('Nyem rau rov pib dua');

Qhov xaus Ln txav mus rau kab tom ntej.

Kauj ruam 5

Tus neeg teb xov tooj ntawm ReadLn nkag mus rau qhov tseem ceeb ntawm cov keyboard, tab sis qhov no nws tsuas tos tus neeg siv ntaus kom ntaus:

ReadLn;

Kauj Ruam 6

Peb ua lub voj xaus:

thaum (tseeb) ua

pib

Lub sijhawm (muaj tseeb) pib txua cov txhais lus: Thaum (mob) ua (). Vim li cas pib ntawm no?

Hauv qhov no, peb xav tau ib tus neeg teb xov tooj sib txuas, uas txhais tau tias thaum lub sijhawm muaj tseeb, muaj ntau tus neeg ua haujlwm tua. Yog tias nws tsis tau pib, tom qab Lub sijhawm, tsuas muaj ib nqe lus raug tua, uas yuav ua rau lub lag luam tsis ua haujlwm. Yuav kom Xaus Cov lus nyob hauv daim ntawv kawg, peb sau kawg.

Kauj Ruam 7

Tam sim no peb pib dua lub txee:

i: = 0;

Kauj ruam 8

Cov lus hais hauv qab no txhais tias: txog thaum ua () tus yuam sij yog nias.

thaum tsis keypressed ua

pib

Tus neeg ua haujlwm ClrScr tshem tawm lub vijtsam:

ClrScr;

Kauj Ruam 9

Peb teeb tsa qhov mob: yog tias lub sijhawm ntev dua 60 thiab qis dua 3600 (qhov no yog qhov tsim nyog yog li thaum lub sijhawm ntau dua li ib teev, qhov kev pab cuam luam tawm tsuas yog dab tsi tom qab tus thib peb yog) tom qab ntawd:

yog tias (i> 60) thiab (i <3600) tom qab ntawd pib

Qhov sib txawv m (feeb) yog sib npaug: vib nas this muab faib los ntawm 60 thiab npawv mus rau pem hauv ntej.

m: = Int (i / 60);

Thiab cov kuj sib txawv thiab s (feeb tsis feeb) yog sib npaug rau: tag nrho cov vib nas this rho tawm feeb muab 60.

s: = i - m * 60;

Kauj ruam 10

Daim Ntawv Sau Tshaj Tawm sau tau pes tsawg feeb thiab vib nas this tau dhau los, thiab kab lus kawg xaus qhov haujlwm ntawm qhov pib ua raws li cov xwm txheej:

Sau (m, 'feeb (s) thiab', s: 1: 2, 'vib nas this (s)')

xaus;

Muaj nuj nqi: 1: 2 txhais tau hais tias vib nas this yuav tsum tau sau nrog ob qhov chaw decimal.

Kauj ruam 11

Yog tias vib nas this tsawg dua 60, tom qab ntawd tsuas yog sau ntau npaum li cas lub vib nas this tau dhau los nrog ob kab zauv:

yog tias kuv <60 ces

Sau ('', i: 1: 2, 'vib nas this (a / s)');

Kauj ruam 12

Yog tias lub vib this ntau dua 3600 (ntawd yog ntau tshaj ib teev) ces:

yog tias kuv> 3600 ces pib

m: = Int (i / 60);

s: = i - m * 60;

ch: = Int (m / 60);

m: = m - ch * 60;

Sau (ch, 'teev (s)', m, 'feeb (s) thiab', s: 1: 2, 'vib nas this (s)');

xaus;

Kauj ruam 13

Yog li, qhov kev zov me nyuam tau sau tias 0 vib nas this dhau, tam sim no nws nce lub txee kuv los ntawm 10 milliseconds, thiab vim tias qhov kev zov me nyuam ua txhua yam tam sim ntawd, peb ua rau ncua sijhawm tib lub sijhawm:

kuv: = i + 0.01;

Ncua (10);

Tom ntej no, peb ua kom qhov kawg rau Lub Sij Hawm (tsis tseem ceeb):

xaus;

Yog hais tias tus neeg siv nias tus yuam sij Sau, tom qab ntawd qhov kev zov me nyuam tos kom nws nias nws dua kom pib lub stopwatch dua:

Readln;

Readln;

Nws tsis yog qhov raug xwm txheej uas peb teeb lub txee rau xoom tom qab Tshaj Tawm (qhov tseeb), vim hais tias thaum tus neeg siv nias nkag mus rau zaum ob, qhov kev zov me nyuam yuav pib txij ntawd mus, rov pib rau lub txee thiab pib suav dua.

Tom ntej no, peb xaus lub sijhawm thiab rau tag nrho cov haujlwm:

xaus;

Kauj ruam 14

Nov yog cov program kom tiav:

siv

CRT;

var

i: Tiag;

s: Tiag;

m: Tiag;

ch: Tiag;

pib

SetWindowTitle ('Stopwatch');

TextColor (Lub Teeb Nruab Nrab);

WriteLn ('Nias Sau kom pib stopwatch');

WriteLn ('Nias ntxiv kom tsum tsis txhob');

Sau ('Nyem rau rov pib dua');

ReadLn;

thaum (tseeb) ua

pib

i: = 0;

thaum tsis keypressed ua

pib

ClrScr;

yog tias (i> 60) thiab (i <3600) tom qab ntawd pib

m: = Int (i / 60);

s: = i - m * 60;

Sau (m, 'feeb (s) thiab', s: 1: 2, 'vib nas this (s)')

xaus;

yog tias kuv <60 ces

Sau ('', i: 1: 2, 'vib nas this (a / s)');

yog tias kuv> 3600 ces pib

m: = Int (i / 60);

s: = i - m * 60;

ch: = Int (m / 60);

m: = m - ch * 60;

Sau (ch, 'teev (s)', m, 'feeb (s) thiab', s: 1: 2, 'vib nas this (s)');

xaus;

kuv: = i + 0.01;

Ruam (10);

xaus;

Readln;

Readln;

xaus;

kawg.

Duab
Duab

Kauj ruam 15

Nws muab tawm tsis zoo nkauj heev, tab sis cov haujlwm ua haujlwm tau zoo!

Pom zoo: