Yuav Ua Li Cas Hloov Cov Hlua Rau Int Pascal

Cov txheej txheem:

Yuav Ua Li Cas Hloov Cov Hlua Rau Int Pascal
Yuav Ua Li Cas Hloov Cov Hlua Rau Int Pascal

Video: Yuav Ua Li Cas Hloov Cov Hlua Rau Int Pascal

Video: Yuav Ua Li Cas Hloov Cov Hlua Rau Int Pascal
Video: Обучение языку Pascal #4. Финал 2024, Hlis ntuj nqeg
Anonim

Pascal yog ib qho ntawm cov lus sau sau ua tsim tsim nyob rau xyoo 1970 los ntawm tus kws tshawb fawb Swiss Niklaus Wirth. Nws yog qhov nrov heev hauv tsev kawm ntawv vim nws yooj yim thiab ua haujlwm zoo.

Yuav ua li cas hloov cov hlua rau int pascal
Yuav ua li cas hloov cov hlua rau int pascal

Cov ntaub ntawv hom

Hauv hom lus programming "Pascal" muaj ob peb hom ntaub ntawv, kev paub txog ntawm cov yam ntxwv ntawm uas yog qhov tsim nyog rau kev sau cov phiaj xwm. Tsuas muaj tsib hom ntaub ntawv tseem ceeb:

  • Cov ntaub ntawv cov lej ib qho lej zauv yog 1 txog 4 bytes ntev thiab muaj qhov tshwj xeeb ntau nyob ntawm seb subtype:

    • Luv luv - los ntawm -128 txog 127
    • Byte - los ntawm 0 txog 255
    • Lo Lus - 0 txog 65535
    • Int - los ntawm -32 768 txog 32 767
    • Ntev - los ntawm -2 147 483 648 rau 2 147 483 647
  • Cov ntaub ntawv tiag tiag yog tus naj npawb ntab nrog ntau qhov loj. Muaj tsib subtypes ntawm no hom ntawm cov ntaub ntawv nyob rau hauv tag nrho:

    • Tiag tiag - los ntawm 2.9 E-39 txog 1.7 E +38
    • Ib Leeg - los ntawm 1.5 E-45 txog 3.4 E + 38
    • Dua zaum ob - los ntawm 5.0 E-324 txog 1.7 E + 308
    • Txuas Ntxiv - txij 3.4E-4951 txog 1.1E + 4932
    • Comp - los ntawm -2 E + 63 txog +2 E + 63 -1
  • Cov ntaub ntawv cov cwj pwm - muaj cov cim ntawm tus niam ntawv. Hauv cov lus nws yog txhais los ntawm cov lus luv "char", tsis muaj subtypes.
  • Cov ntaub ntawv kab ntawv yog cov kab lus ntawm cov cim sau ua "hlua".
  • Cov ntaub ntawv Boolean - sawv cev los ua qhov tseeb lossis cuav.

Kev txhais ntawm ib hom ntaub ntawv mus rau lwm qhov

Qee lub sij hawm nws yuav tsum ua haujlwm ib txhij nrog ntau cov ntaub ntawv. Piv txwv li, yog tias koj sau kab lus "45 + 45" rau hauv hom "int", tom qab ntawd thaum ua haujlwm, qhov program yuav tso tawm cov lej ntawm cov lej no. Qhov xwm txheej txawv nrog txoj hlua sib txawv. Thaum sau tib qho kev hais tawm, tsis hais tus lej "4545" lossis qhov qhia nws tus kheej yuav tshwm rau ntawm lub vijtsam, nyob ntawm qhov muab tso rau ntawm cov cim hais qhia. Cov haujlwm ua lej tsuas yog ua tau siv cov lej lossis hom ntawm cov ntaub ntawv, vim tias tsuas yog lawv ua haujlwm ntawm cov lej xwb.

Piv txwv li, cia peb pom qhov lej ntawm 2 thiab 3 siv cov lus Pascal programming.

Duab
Duab

Txij li thaum sau tus lej ntawm cov ntaub ntawv siv, thaum qhov kev zov me nyuam pib, tsuas yog qhov tshwm sim ntawm qhov tawm ntawm tus lej ob tshwm. Yog tias xav tau los tsim cov lus teb kom zoo nkauj, ces koj yuav tsum siv cov ntaub ntawv xov xwm. Qhov no tuaj yeem ua tiav hauv ib kab lossis ob sab. Thawj txoj hauv kev yog qhov yooj yim tshaj plaws, vim nws tsis tas yuav txhais los ntawm "rau" rau "hlua".

Duab
Duab

Ob kab tshwm ntawm qhov screen. Thawj kab qhia tau dab tsi ua haujlwm, thiab kab thib ob qhia txog nws qhov tshwm sim. Nov yog ib txoj kev uas koj tuaj yeem siv tau ntau yam ntaub ntawv. Txawm li cas los xij, nrog nws cov kev pab nws yuav tsis tuaj yeem hloov kho cov ntawv sau yog tias koj xav tau sau ob peb kab lus. Yuav kom daws tau qhov teeb meem no, koj yuav tsum nkag mus hloov pauv thiab siv lawv hloov cov ntaub ntawv numeric mus rau cov hlua.

Duab
Duab

Yog li, peb tau txais ob kab lus, txhua tus uas tau sau rau ntawm ib kab. Kev siv txhais lus ntawm kev hloov pauv ntawm hom "txoj hlua" rau hauv kev hloov pauv ntawm hom "int" yog ib qho ntawm feem ntau thiab siv tas li. Lwm cov hom ntaub ntawv tuaj yeem hloov pauv tib txoj kev.

Pom zoo: