Pascal Language String Question 10

Updated on technology 2024-03-27
3 answers
  1. Anonymous users2024-02-07

    Strange indeed, the result of my experiment is that if the string variable is initialized first, the subscript can be used to read and write the string variable normally.

    varname1,name2:string[15];

    i,s:integer;

    beginread(name1);

    name2:=' ';Here, name2 is initialized to 4 spaces.

    s:=length(name1);

    for i:=s downto 1 do name2[s-i+1]:=name1[i];

    writeln(name2);

    end.When the program is running, enter ABCD and output DCBAHowever, if you input ABCDEF, you can only output fedcThat is, the program can only "fill" the length of the space opened up at initialization.

    But what is puzzling is that if you use the subscript to read each bit of the name2 string variable, it will be displayed:

    for i:=1 to 6 do write(name2[i]);

    If this is the case, you can output fedcba. by entering abcdefIt shows that there are things in name2[1] to name2[6], but there are only fedc. in name2Studied but cannot comprehend!

  2. Anonymous users2024-02-06

    1.program sdf; var a:string; squyci,j:longint; begin readln(a); while a<>'#&39; do begin s:

    0; j:=0; for i:=1 to length(a) do if a[i] in [&39;0'..39;9'] then j:

    j*10+ord(a[i])-ord('0') else begin s:=s+j; j:=0; end; s:

    s+j; writeln(s); readln(a); end;end Others want answers, send me a message adfj right now.

  3. Anonymous users2024-02-05

    When do we need to define an array?

    When you need to process large amounts of the same type of data.

    How are arrays stored?

    Stored to a contiguous memory space.

    What are the advantages of this type of storage?

    It can be processed sequentially, sequentially.

    What are the disadvantages of such storage?

    The data is processed sequentially by relying on the adjacency of the data; If you want to insert or delete array elements, you need to move a large number of array elements to maintain this adjacency.

    5.What are the advantages of string operations and their functions?

    Manipulating strings is simple; Functions are originally subprograms, which realize a certain string operation function, and there is no need to write such subprograms by yourself.

Related questions
6 answers2024-03-27

Use the ITOA function.

Prototype: extern char *itoa(int i); >>>More

5 answers2024-03-27

Add a field in Table 1 as a foreign key and Billno in Table 2 >>>More

7 answers2024-03-27

Do it by your train of thought.

Method 1. string strnumber="200m"; >>>More

11 answers2024-03-27

Valid character constants are:

a.'084' is not legal, there is no 8 in octal. >>>More

10 answers2024-03-27

There is no difference between a string and an array of characters. >>>More