Two simple pascal questions

Updated on educate 2024-04-05
4 answers
  1. Anonymous users2024-02-07

    I just did this topic 77 is a classic Josephian problem that is very famous in algorithm design, the monkey chooses the king, the number is reported with a password, and the fox chases the rabbit is its variation.

    The monkey elects the king:

    program y5_6;

    varn,m,s,f,t:integer;

    a:array[1..100] of boolean;

    beginreadln(n);

    m:=3;for t:= 1 to n doa[t]:=false;

    f:=0; t:=0; s:=0;

    repeat

    t:=t+1;

    if t=n+1 then t:=1;

    if a[t]=false then s:=s+1;

    if s=m then

    begins:=0;

    a[t]:=true;

    f:=f+1;

    end;until

    f=n-2;

    for t:=1 to n do

    if not(a[t]) then

    beginwrite(t);

    exit;end;

    end.The fox chases the rabbit:

    program y5_7;

    var i,j:integer;

    a:array[0..9] of integer;

    beginfor i:= 0 to 9 do a[i]:=1;

    j:=0;for i:= 1 to 1000 do beginj:=(j+i) mod 10 ;

    a[j]:=0;

    end;for i:= 1 to 9 do if a[i]=1 then write(i:3);

    if a[0]=1 then write(' 10');

    end.

  2. Anonymous users2024-02-06

    1 is the first of course and he always counts 1

  3. Anonymous users2024-02-05

    For example, at the beginning, 10,000 yuan is a monthly interest.

    Then after the first month, due to the monthly interest, you owe the bank a total of 10,000 * (1 + yuan), and then you pay the yuan and still owe the yuan.

    2nd month: due to the monthly interest arrears.

    If you pay the yuan again, you still owe the yuan.

    And so on. By the tenth month, the arrears of about $ are almost 0, so the monthly payment is.

    My thoughts: do it with dichotomies.

    Left Boundaryl Right BoundaryrMiddlem=(L+R) 2If m satisfies the condition, then L=M, otherwise R=M until the gap between l and r is within the border, if you don't ask me directly.

  4. Anonymous users2024-02-04

    The number of months means that you have to repay in a few months, and the number of months * monthly interest is the interest you have to pay, plus the amount of the loan is 10,000; Divide by the number of months, and it is the monthly payment;

    If you want to **, just tell me your email and I'll send it to you.

Related questions
15 answers2024-04-05

It is supposed to usher in the dawn of dawn at the eastern point and send away the sunset at dusk, but the earth is round, so there is no one in the easternmost place, so there is an international date line on the globe to distinguish the date and determine which place first ushered in the morning sun.

16 answers2024-04-05

The total area is 3 * square centimeters, so the square of the side length of 225 = 15 centimeters.

18 answers2024-04-05

Answer D Analysis: Taking the passenger as the reference, the relative direction of movement of the motorcycle is the northwest direction, and the relative movement speed is decomposed into the velocity v0 in the west direction and v1 in the north direction. >>>More

13 answers2024-04-05

1) Proof of: CEF=90°

aef+∠afe=∠aef+∠ced=90°∴∠afe=∠ced >>>More

6 answers2024-04-05

Refer to the upstairs, but upstairs doesn't know then without adding a statement? >>>More