-
Refer to the upstairs, but upstairs doesn't know then without adding a statement?
var i,d:longint;
beginfor i:=1 to 4 do to start the loop.
begind:=0;Initialize, tell the truth and zero in.
if i<>1 then
d:=d+1;A: I didn't do anything bad. Satisfy the truth if i=3 then
d:=d+1;B: C has done something bad, and is satisfied with the truth if i=4 then
d:=d+1;C: D has done something bad, and is content to tell the truth if i<>4 then
d:=d+1;Ding: C is wronged! , content for the truth.
if d=3 then the truth is 3 sentences in total.
beginwrite(i);Outputs the number of the offender.
end; end;
end.
-
A: I didn't do anything bad, true
B: C did something bad true
C: D did something bad false
Ding: C is wronged! true
Reason: Only then is it logical.
-
A simple analysis shows that one of Bingding told a lie. If C tells a lie, C has done something bad. If Ding told a lie, then C and D both did bad things and contradicted the question.
4 can be left without looping. If you must use it, you can use a structure like this:
for a:=0 to 1
for b:=0 to 1
Begin writes logical statements based on what everyone says.
end;is only a shallow learner, and please guide you!
-
program ff;
vari,d:longint;
beginfor i:=1 to 4 do (one is a criminal) begind:=0; (Tell the truth to zero).
if i<>1 then d:=d+1;A: I didn't do anything bad. , content for the truth.
if i=3 then d:=d+1;If i=4 then d:
d+1;If i<>4 then d:=d+1; (D:.)
C wronged people! , content for the truth.
if d=3 then
beginwrite(i);(the first few outputs are criminals) break; (End Loop).
end;end;
end.C lied and is a criminal.
-
for statement.
structure: for loop control variable: =initial value to downto terminate value do statement;
Features: Counting loops, knowing the number of loops or the beginning and end of the loop sequence.
Note: 1. The types of variables, initial values, and termination values must be the same, and cannot be real numbers;
2. The initial value and the termination value can also be expressions;
3. Add the ...... to the sentence when it exceeds one sentenceend;
4. The cycle control variable will automatically change from the initial to the termination, and the value of the cycle control variable cannot be forced to be manually changed during operation;
5. to is from small to large, that is, the initial value is less than the termination value, and downto is from large to small, that is, the initial value is greater than the termination value.
Current-type cycles. structure: while Boolean expression do statement;
Significance: When the value of the Boolean expression is true, the statement after do is executed repeatedly.
Procedure: 1. Determine the value of the Boolean expression, if true, go to step 2, otherwise go to step 4;
2. Execute the statement after do;
3. Return to step 1;
4. At the end of the loop, execute the next statement after while.
Note: For loops are special type loops.
Until the type cycle.
Structure: repeat
Statement 1; Statement 2;
statement n; until Boolean expression.
Significance: The specified sequence of statements is executed repeatedly until the specified condition is true.
Procedure: Execute the specified statement sequence first, then identify the condition, and when the condition is not true, continue to execute the specified statement sequence, and repeat until the condition is established.
Note: 1. repeat executes the statement first, and then judges the condition; while first determines the condition, and then executes the statement;
2. There is no need to use begin and end for compound statements in repeat, and only one statement or one compound statement can be used in while;
3. repeat is repeated when the condition is not true, and repeated when the condition is established (the conditions of these two cycles are exactly complementary to each other);
4. repeatRegardless of whether the condition is true or not, the specified statement sequence must always be executed once, and if the condition is not true at the beginning, the specified statement in the loop will not be executed.
-
amod
b is the remainder after a divides by b, such as 12
mod5=2, knowing that this calculation is actually very simple, is more.
s=0s=(10mod
s=(9mod
The whole calculation process is as follows.
s=(10mod
s=(9mod
s=(8mod
s=(7mod
s=(6mod
s=(5mod
s=(4mod
s=(3mod
s=(2mod
s=(1mod
s=(10mod
s=(9mod
s=(8mod
s=(7mod
s=(6mod
s=(5mod
s=(4mod
s=(3mod
s=(2mod
s=(1mod
s=(10mod
s=(9mod
s=(8mod
s=(7mod
s=(6mod
s=(5mod
s=(4mod
s=(3mod
s=(2mod
s=(1mod
s=(10mod
s=(9mod
s=(8mod
s=(7mod
s=(6mod
s=(5mod
s=(4mod
s=(3mod
s=(2mod
s=(1mod
s=(10mod
s=(9mod
s=(8mod
s=(7mod
s=(6mod
s=(5mod
s=(4mod
s=(3mod
s=(2mod
s=(1mod
s=(10mod
s=(9mod
s=(8mod
s=(7mod
s=(6mod
s=(5mod
s=(4mod
s=(3mod
s=(2mod
s=(1mod
s=(10mod
s=(9mod
s=(8mod
s=(7mod
s=(6mod
s=(5mod
s=(4mod
s=(3mod
s=(2mod
s=(1mod
s=(10mod
s=(9mod
s=(8mod
s=(7mod
s=(6mod
s=(5mod
s=(4mod
s=(3mod
s=(2mod
s=(1mod
s=(10mod
s=(9mod
s=(8mod
s=(7mod
s=(6mod
s=(5mod
s=(4mod
s=(3mod
s=(2mod
s=(1mod
s=(10mod
s=(9mod
s=(8mod
s=(7mod
s=(6mod
s=(5mod
s=(4mod
s=(3mod
s=(2mod
s=(1mod
The first office has a 9% chance of having a pen, the second office has a 9% chance of not having a pen (i.e., 3 people don't have a pen with a pen) is (1-3%) (1-3%), and the chance of having a pen is 1-(1-3%) (1-3%) (1-3%) >>>More
Categorize 1 to 50 and divide them into 7 divided by 7 and divisible by 7, with 8 remaining 1 and 1 remaining and 7 others. In the same way, the elements of the remaining 2 and the remaining 5 cannot exist at the same time, the remaining 3 and the remaining 4 cannot exist at the same time, and the divisible can only exist in one element at most, so at most there are 8 remaining 1, the remaining 2 or 5 choose one category, the remaining 3 or 4 choose one category, and the divisible one can be selected, a total of 23.
Combine the two formulas and get it.
k/x=-x-6 >>>More
Choose A, B, C
Because the stem does not say whether acceleration is the same as velocity or opposite. >>>More
It's not very hard that the tail node next points to null. >>>More