How to use the Pascal language to encode addition and subtraction operations within 254 bits

Updated on educate 2024-04-08
15 answers
  1. Anonymous users2024-02-07

    program p1383;

    vars:string;

    x:array[1..maxint] of string;

    f:array[1..maxint] of boolean;

    a,b:array[1..maxint] of longint;

    i,j,n,w,t,m:longint;

    y:int64;

    beginreadln(s);

    n:=ord(s[0]);

    w:=1;m:=1;y:=0;

    for i:=1 to n do

    beginif s[i]='+' thenbeginf[w]:=true;

    b[w]:=i;

    end;if s[i]='-' then

    beginf[w]:=false;

    b[w]:=i;

    end;if (s[i]='+') or (s[i]='-') then

    w:=w+1;

    end;t:=1;

    for i:=1 to w do

    beginif ibeginfor j:=m to b[i]-1 dox[t]:=x[t]+s[j];

    val(x[t],a[t]);

    t:=t+1;

    m:=1+b[i];

    end;if i=w then

    for j:=m to n do

    beginx[t]:=x[t]+s[j];

    val(x[t],a[t]);

    end;end;

    y:=a[1];

    for i:=1 to w-1 do

    beginif f[i]=true theny:=y+a[i+1];

    if f[i]=false then

    y:=y-a[i+1];

    end;writeln(y);

    end.Compiled through.

    Test data 1: The answer is correct. 0ms

    Test data 2: The answer is correct. 0ms

    Test data 3: The answer is correct. 0ms

    Test data 4: The answer is correct. 0ms

    Test data 5: The answer is correct. 0ms

    Test data 6: The answer is correct. 0ms

    Test Data 7: Correct Answer. 0ms

    Test data 8: The answer is correct. 0ms

    Test Data 9: Answer is correct. 0ms

    Test data 10: Correct answer. 0ms

    accepted valid score: 100 valid time: 0ms

  2. Anonymous users2024-02-06

    High-precision algorithm that uses arrays to store every digit. For example, 12345 is stored as: array[1,2,3,4,5].

  3. Anonymous users2024-02-05

    Two methods:

    1. Turn the number into a string (only valid for integer numbers).

    vara:longint;

    l:integer;

    s:string;

    beginreadln(a);

    str(a,s);

    l:=length(s);

    writeln(l);

    end.2. Use a repeat or while loop (although real can accept real numbers, but the decimal part will be ignored).

    repeat loop method:

    vara:real;

    b:integer;

    beginreadln(a);

    repeat

    a:=a/10;

    b:=b+1;

    until trunc(a)=0;

    writeln(b);

    end.while loop method:

    vara:=real;

    b:=integer;

    beginreadln(a);

    while trunc(a)<>0 do

    begina:=a/10;

    b:=b+1;

    end;writeln(b);

    end.

  4. Anonymous users2024-02-04

    var s,i:longint;

    begins:=0;

    for i:=1 to 99 do

    if odd(i) then s:=s+i;

    writeln(s);end.

    I haven't compiled this, you can try it yourself.

    Explanation: s is the sum.

    i is a cyclic variable.

    Let i exhaust from 1 to 99.

    The odd function is used to determine whether it is an odd number or not. If it is an odd number, the function value is true, otherwise it is false.

    After judging whether i is an odd number, if it is an odd number, it is added, and if it is not an odd number, it is left alone.

    Got it? If you get it, choose me!!

    If you don't understand, send me a message.

    If you have any questions, please feel free to accompany you.

  5. Anonymous users2024-02-03

    var i,s:longint

    beginfor i:=1 to 99 do loop from 1 to 99.

    if odd(i) then s:=s+i;If i is an odd number, add it up.

    writeln(s);

    end.

  6. Anonymous users2024-02-02

    It's the easiest.

    for i:=0 to 49 do sum:=sum+i*2+1;

    If you see what's above, don't lose sight of what's below.

  7. Anonymous users2024-02-01

    It's very simple, you can store the data at once, and 20 points is a little less!!

  8. Anonymous users2024-01-31

    In order, the first one is satisfied, and then the next one will not be executed, so it is only executed.

    You take care to understand what else means"Otherwise"

    Since they are"Otherwise"Therefore, the previous conditions must not be met, so the content of Otherwise, it is necessary to execute the content.

    It's just that otherwise it's just another if statement.

  9. Anonymous users2024-01-30

    If you find the first one that matches, execute the then following statement, and then skip to the next semicolon to continue.

  10. Anonymous users2024-01-29

    (Master, hehe) only executes one statement. Keep in mind that this if set of else statements will always only be executed once. Since the first one is satisfied, then only execute".

  11. Anonymous users2024-01-28

    vari,sum,n:longint;

    beginread(n);

    for i:=1 to n do is controlled by a loop, and each number goes through the begin

    s:=s*i;Multiply, so that it will be multiplied from 1 to n, in fact, it is more formal for i:=n downto 1 do but I'm afraid you don't understand, that is, n is reversed to 1

    end;writeln(s);Hit s (for sum).

    end.

  12. Anonymous users2024-01-27

    o, that d3 enters the late game, and most players have a variety of varieties throughout the year.

    Preferential and ** activities, so that you only need to hold the mold with the continuation of the withdrawal, but also give us a book on the device to say goodbye.

  13. Anonymous users2024-01-26

    You leave an email or QQ and I'll send it to you.

  14. Anonymous users2024-01-25

    I really want the answer, can you give me a copy?

  15. Anonymous users2024-01-24

    You can debug this in fp.

    It's clear.

Related questions
4 answers2024-04-08

The Pascal compilation system is a system software. Pascal is the first structured programming language with rigorous syntax, clear hierarchy, easy to write and readable programs. Pascal language is widely used in various software, and the program is divided into name (self-proposed after program), setting (defined after var), start (begin), program (body), read (read read ln), and end (end), with strong structural hierarchy, rigorous and tight. >>>More

7 answers2024-04-08

Modify network parameters? Can you elaborate on what you want to change?

4 answers2024-04-08

varn,i,j:integer;

beginreadln(n); >>>More

3 answers2024-04-08

Summary. Here's a simple clock written in C** that prints out the current time (in hours, minutes, and seconds): include include int main() return 0; This ** uses the time function and the localtime function in the header file, as well as the printf function and the fflush function in the header file. >>>More

2 answers2024-04-08

Yi Language is a self-developed Chinese programming language that is suitable for national conditions and is easy to learn and use for people of different levels and professions. Easy Language lowers the threshold for the majority of computer users to program, especially users who do not know English at all or have little understanding of English, can enter the door of Windows programming extremely quickly by using this language. Yi Language Chinese Programming Environment is a programming tool environment that supports programming based on Chinese characters and words, fully visualized, and cross-mainstream operating system platforms. Available in simplified and traditional Chinese, English, Japanese and other languages; Able to call to and from commonly used programming languages; It has interfaces and supporting tools that make full use of various resources such as API, COM, DLL, OCX components, various mainstream databases, and various utilities. >>>More