Cov txheej txheem:

Koj sau tus qauv nyob deb li cas hauv Java?
Koj sau tus qauv nyob deb li cas hauv Java?

Video: Koj sau tus qauv nyob deb li cas hauv Java?

Video: Koj sau tus qauv nyob deb li cas hauv Java?
Video: Cas Tsis Xaiv Koj - R-Lin Thoj New Song Original By Zaj Dub [Official MV] 2023 2024, Tej zaum
Anonim

1 . Java Program siv tus qauv tsim nyog

  1. ntshuam java ua . lang. lej. *;
  2. class DistanceBwPoint.
  3. pej xeem static void main(String arg)
  4. {
  5. ib x1,x2,y1,y2;
  6. ob chav;
  7. x1=1;y1=1;x2=4;y2=4;
  8. dis = Math. sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));

Khaws qhov no hauv kev txiav txim siab, ua li cas koj sau tus qauv nyob deb hauv Python?

Txhawm rau xam qhov kev ncua deb ntawm ob lub ntsiab lus, koj tsuas yog ua tau

  1. import lej.
  2. def xamDistance(x1, y1, x2, y2):
  3. dist = math.sqrt((x2 - x1)**2 + (y2 - y1)**2)
  4. rov dist.
  5. print xamDistance(x1, y1, x2, y2)

Dab tsi yog txhais los ntawm Euclidean nrug? Hauv lej, the Euclidean nrug los yog Euclidean metric yog qhov "zoo tib yam" ncaj-kab nyob deb nruab nrab ntawm ob lub ntsiab lus hauv Euclidean qhov chaw. Nrog qhov no nyob deb , Euclidean qhov chaw dhau los ua qhov chaw metric. Cov qauv sib txuas yog hu ua Euclidean cai. Cov ntawv qub hais txog qhov ntsuas raws li Pythagorean metric.

Kuj paub, koj ua li cas xam Euclidean nrug?

xam tus Euclidean nrug rau ib qhov ntev. Cov nyob deb nruab nrab ntawm ob lub ntsiab lus hauv ib qhov ntev tsuas yog qhov tseeb ntawm qhov sib txawv ntawm lawv cov kev tswj hwm. Ua lej, qhov no qhia tau tias |p1 - q1| qhov twg p1 yog thawj qhov sib koom ua ke ntawm thawj lub ntsiab lus thiab q1 yog thawj qhov kev sib koom tes ntawm qhov thib ob.

Yuav ua li cas square hauv Java?

Squaring tus lej hauv Java tuaj yeem ua tiav ob txoj hauv kev. Ib qho yog los ntawm kev muab tus lej los ntawm nws tus kheej. Lwm qhov yog los ntawm kev siv lej. pow() muaj nuj nqi, uas yuav siv sij hawm ob tsis: tus naj npawb raug hloov thiab lub hwj chim uas koj tab tom tsa nws.

Pom zoo: