ComputersProgramming

Yuav ua li cas yog lub div rau "Pascal"? Tsis tas li ntawd, cov lus teb thiab piv txwv

Txhua txhua xyoo qhov kev thov rau programmer profession. Thaum lub caij sau cov lis dej num yog lug siv nyob ib ncig ntawm ib lub teb lus nyob rau txawv muaj ntau seem. Nyob rau hauv thiaj li yuav ua tus txheej txheem ntawm kev kawm computer programming ntau, high school cov tub ntxhais kawm thiab cov tub ntxhais kawm ntawm 1-2 kev kawm no qhia thawj los tsim koj tus kheej daim ntaub ntawv nyob rau hauv cov lus "Pascal". Operations div thiab mod, thiab lwm yam suav nyob rau hauv nws cov midst tus tsom xam ntawm no tsab xov xwm.

Ob peb lo lus ntawm cov lus Pascal

"Pascal" yog tsim nyob rau hauv 1968-1969 los ntawm lub npe nrov paub txog Niklaus Wirth, uas tom qab muab tsub lub Turing puav pheej thiab muaj puav pheej "Pioneer ntawm computer technology." Xeem ua ntej nws koom nyob rau hauv txoj kev loj hlob ntawm tus txheej txheem lus "Algol-68." Nyob rau hauv ib tsab xov xwm luam tawm nyob rau hauv 1970, lub hom phiaj tseem ceeb ntawm nws ua hauj lwm Wirth hu ua lub creation ntawm ib tug cuab yeej zoo heev uas siv structured programming thiab cov ntaub ntawv.

Tom qab, cov lus "Pascal" tau muaj ib tug enormous tej yam nyob rau hauv lub teb ntawm cov ntaub ntawv technology, ua ib tug ntawm lub hauv paus. Yuav kom qhov no hnub twg, nws yog raws li nyob rau hauv nws ua ib tug kws cob qhia programming nyob rau hauv ntau ntawm cov kev universities ntawm lub ntiaj teb no.

Yuav ua li cas yog lub integer faib

Nyob rau hauv kev kawm txog zauv, nyob rau hauv lub title to taub lub lag luam ntawm ob zauv. Raws li ib tug tshwm sim ntawm lub integer faib ntawm ib tug ntawm lawv mus rau lwm lub, nws yog ib lub integer ib feem ntawm lub quotient. Nyob rau hauv lwm yam lus, yog hais tias:

24: 6 = 4;

100: 3 = 33

55: 6 = 9;

thiab li ntawd.

Integer faib tseem hu ua lub nrhiav ib nrab quotient.

Nco ntsoov tias nrog lub lag luam no, yog hais tias tus nqi yog me dua cov divisor, qhov tshwm sim yog pes tsawg.

Txhais cov kev tshwm sim ntawm lub integer faib mus rau ib tug b, ob qho tib si q. ces

t. e. lub division ua nyob rau hauv lub li ib txwm txiav txim siab zoo, ua raws li los ntawm pub muab kwv yees cov mus rau qhov ze integer me sab.

Lag luam nyob rau hauv div "Pascal"

div - Nyob rau hauv peb cov lus muab ib tug tshwj xeeb xov tooj rau integer faib. Cov kev qhia Pascal, cov mis uas yog hais saum toj no, yuav muaj daim ntawv:

q: = ib tug div b.

Yog hais tias peb yuav sib tham txog constants, Piv txwv li, ib tug = 50 thiab b = 9, ces peb yuav muaj q: = 50 div 9. Raws li ib tug tshwm sim, q yuav ua ncaj rau 5.

Muab xam rau ntawm qhov nqi koj tshuav

Lag luam nyob rau hauv div "Pascal" yog feem ntau kawm nrog cov mod. Ua ntej peb yuav nrhiav tau tawm yog dab tsi lub ntsiab lus ntawm no cov ntaub ntawv, saib yuav ua li cas koj yuav nrhiav tau tus so ntawm tus xov tooj.

Obviously, nws yuav pom siv ib tug nqi tau raws li ib tug tshwm sim ntawm lub integer faib, piv txwv li. E.

r = ib tug - bx q.

Lag luam mod nyob rau hauv "Pascal"

Nyob rau hauv Pascal, nrhiav cov uas tseem tshuav yuav ua tau heev yooj yim. Rau cov hom phiaj yog muab ib tug binary neeg teb xov tooj mod.

Nws yog sau raws li nram no:

r = ib tug mod b.

Yog hais tias, piv txwv li, ib tug = 50 thiab b = 9, ces peb muaj r: = 50 mod 9. Raws li ib tug tshwm sim, r yog sib npaug zos rau 4.

ua daim ntawv thov

Nrhiav cov seem ntawm faib (r) yog siv nyob rau hauv xam thiab telecommunications. Nrog xws tswj haujlwm yog generated, thiab random tooj nyob rau hauv ib tug tsawg ntau yam.

mod neeg teb xov tooj, thiab yog siv los txiav txim seb tus multiplicity ntawm tus xov tooj, m. e. divisibility ntawm ib tug naj npawb los ntawm lwm nrog ib tug integer tshwm sim. Obviously, cov no yog cov ib khub ntawm cov zauv, rau cov uas qhov tshwm sim ntawm ua ntawv thov cov neeg teb xov tooj muab ib tug 0 mod.

Nyob rau hauv lub "Pascal" multiplicity mob no yuav tau sau ntawv raws li:

Yog hais tias ib tug mod b = 0 ces sau ntawv (a, 'quav', b).

Piv txwv li, thaum lub caij pib mob code kaw saum toj no rau lub qhov tseem ceeb ib tug = 4 thiab b = 2 nyob rau hauv cov saib yuav tso saib lub inscription "4 fold 2".

Nyob rau hauv tas li ntawd, cov neeg teb xov tooj mod yuav siv tau los tso saib kawg lej ntawm tus xov tooj nyob rau hauv decimal cim. Ua li no, siv cov siv r = ib mod 10. Piv txwv li, qhov hais kom ua r = 37 mod 10 7 yuav muab cov kev tshwm sim.

neeg teb xov tooj trunc

Yog lwm teb xov tooj, uas koj yuav tau txais tib tshwm sim raws li los ntawm ib tug div rau "Pascal". Nws yog hais txog trunc, uas siv tsis tau tsuas yog rau cov zauv. Nws outputs cov li lub integer feem ntawm lub fractional sib cav. Ua ke nrog cov neeg teb xov tooj "ib txwm" tau los mus faib cov tib yam. Xav txog cov saum toj no piv txwv. Cia ib = 51 thiab b = 9. Ces los ntawm qhov hais kom ua q: = 51 9 div tau q: = 5, peb tau raws li ib tug tshwm sim ntawm pub muab kwv yees. Yog hais tias, txawm li cas los, thov mus rau cov tib tooj ntawm cov tswv trunc, ces q: = trunc (51/9) yuav q: .. = 5, piv txwv li, muaj cov tib yam.

QAUV 1

Xav txog seb koj yuav siv div thiab mod nyob rau hauv lub "Pascal" los daws kom tau cov tswv yim muaj teeb meem. Xav tias koj yuav tsum nrhiav tus sum ntawm tug lej tom qab ntawm ib tug ob-tus lej. Cov kev xav raws li nram no:

  • Raws li twb tau hais saum toj no, qhov kawg ntawm lub xaus-npawb tsab nyob rau hauv lub xov tooj tej zaum yuav muab tau los ntawm kev thov rau nws thiab rau tus xov tooj 10, tus neeg teb xov tooj mod;
  • Raws li tus thawj hauv xov tooj, ces nws yuav tig tawm, yog tias koj hloov tus mod rau pab neeg no nyob rau hauv lub div "Pascal".

Peb sau cov code rau cov lus "Pascal". Nws yuav saib raws li nram no:

kev pab cuam Sum_2; (Program lub npe)

var Number, Number1, Number2, Tawm: integer; (A qhia txog ntau yam thiab txiav txim seb lawv hom raws li ib tug integer)

pib (pib ntawm qhov kev pab cuam hauv lub cev)

sau ntawv ( 'tswv yim Ob-lej'); (Dai daim kab lus "Tswv yim Ob-lej")

nyeem (Number); (Cov tswv yim pib tooj)

Number1: = Number div 10; (Muab xam los ntawm cov thawj zauv)

Number2: = Number mod 10; (Muab xam los ntawm lub thib ob ntiv)

sum: = Number1 + Number2; (Muab xam los ntawm cov nyiaj ntawm cov zauv)

sau ntawv (Tawm); (Tshwm sim tso zis rau lub screen)

kawg.

Rau tus xov tooj 25, qhov tshwm sim ntawm kev siv qhov kev pab cuam yog 7, thiab, piv txwv li, 37 - 9.

QAUV 2

Sau cov code rau ib qho kev pab uas laij cov lej ntawm lub xaus-npawb tsab 3-tus lej.

Yuav ua li cas mus nrhiav tau qhov tseeb daim duab - yog to taub. Nws tsis yog tham thiab muab xam rau ntawm lub 1st. Nws tshwm sim raws li ib tug tshwm sim ntawm ua ntawv thov cov neeg teb xov tooj div rau "Pascal" rau tus xovtooj no thiab 100. Nws tseem mus txiav txim seb yuav ua li cas nrhiav tau tus thib ob tug ntiv. Ua li no, koj yuav siv tau ib tug ntau sophisticated tsim, uas yog tau yog hais tias mus rau tus thawj tooj, thiab mus thov cov neeg teb xov tooj div 10, thiab ces mus rau lub txiaj ntsim thiab mus rau 10 lub teb xov tooj mod.

txoj kev pab code rau xam cov sum ntawm tug lej tom qab ntawm ib tug peb tug lej xov tooj yuav tsum tau raws li nram no:

kev pab cuam Sum_3; (Program lub npe)

var Number3, Tawm: integer; (A qhia txog ntau yam thiab txiav txim seb lawv hom raws li ib tug integer)

pib (pib ntawm qhov kev pab cuam hauv lub cev)

sau ntawv ( 'tswv yim Tsob ntoo-lej'); (Dai daim kab lus «Tswv yim Tsob ntoo-lej»)

nyeem (Number3); (Cov tswv yim pib tooj)

Tawm: = Number3 div 100 + Number3 mod 10 + Number3 div 10 mod 10; (Muab xam los ntawm cov nyiaj)

sau ntawv ( 'Tawm); (Tshwm sim tso zis rau lub screen)

kawg.

ib co sau ntawv

Nco ntsoov tias cov pa division lag luam thaum ua ntawv thov rau integer nqe lus tshaj lawv cov chav kawm ntawv. Qhov no fundamentally distinguishes nws los ntawm cov lag luam uas nyob rau hauv div "Pascal", raws li zoo raws li lub mod neeg teb xov tooj, uas muab lub txiaj ntsim raws li ib tug zauv.

Qhov kev txiav txim ntawm tua ntawm binary hom haujlwm (m. E. Tau 2 operands) nyob rau hauv ib tug complex qhia yog txiav txim los ntawm lawv ua ntej thiab koov. Nyob rau hauv lwm yam lus, yog hais tias muaj yog nkhaus yog soj ntsuam thawj zaug nyob hauv lawv qhia ntawm sab laug mus rau sab xis. Cov hauj lwm *, /, mod thiab div yog ntau dua ua ntej tshaj li tus + thiab -. Yog hais tias lub nkhaus yog tsis tam sim no, ua ntej los ntawm sab laug mus rau sab xis yuav tsum ua yeeb yam nrog ntau dua feem, thiab ces - + thiab -.

Tam sim no uas koj paub tias dab tsi rau cov kev ua yog siv nyob rau hauv lub div "Pascal". Koj kuj paub lub caij muaj kev siv mod neeg teb xov tooj ntawd, tseeb, yuav pab tau koj los tsim koj tus kheej daim ntaub ntawv.

Similar articles

 

 

 

 

Trending Now

 

 

 

 

Newest

Copyright © 2018 hmn.birmiss.com. Theme powered by WordPress.