Ask the experts about files and strings in pascal

Updated on technology 2024-02-09
4 answers
  1. Anonymous users2024-02-05

    I don't dare to be a noi master, but I have participated in noip.

    val(copy(s,pos('=',s)+1,pos(' ',s)-pos('=',s)-1),p,t);

    delete(s,1,pos(' ',s));

    val(copy(s,pos('=',s)+1,pos(' ',s)-pos('=',s)-1),q,t);

    It seems that there is no such data, generally.

    Let you read. Don't worry.

  2. Anonymous users2024-02-04

    The Turbo Pascal language provides the following standard functions in which the argument is a character, where CHR is a character.

    Successor function succ(ch): e.g., succ('8')='9’ succ (’e’)='f’

    For the last character of the character set, the succ function is meaningless.

    Pred (ch): e.g., pred ('7')='6’ pred (’b’)=' a’

    Ordinal function ord (ch): Gives the ordinal number of the character ch in the ASCII character set, and the result is an integer.

    Note: ord ('7')<7, the correct one is: ord ('7')=ord('0')+7=48+7=55

    If ch is a numeric character, then ord (ch) - ord ('0') is the numeric value of the numeric character, for example: ord ('7')-ord('0')=7

    The character function chr (i) described earlier is the inverse of ord (ch), e.g. chr (55) = '7' chr (ord('a'))='a’

    4. Boolean type functions.

    The Turbo Pascal language provides Boolean functions, mainly several character functions.

    ord (b) e.g. ord (false)=0 ord (true)=1.

  3. Anonymous users2024-02-03

    1.Strings are used to store entire batches of character data. Strings are commonly used in programming to store characterized numeric data.

    For example, when performing high-precision operations, operands and calculation results are stored. Strings can be treated as special arrays of strings. Of course, it also has its own characteristics.

    Here's the format of the string definition:

    vars:string;

    s1:string[15];

    If the length of a string is not specified, the space is allocated according to the maximum length of the type (255 characters), and the maximum available length is 255. If a specific value (between 1 and 255) is given in parentheses, the space is allocated according to the size of the value. When used, the maximum usable length is this value.

    2.Input, output of strings:

    The string type can be input and output as an array, or directly input and output: readln(s); writeln(s);When multiple strings are entered, carriage return is used as the separator between data; Each readln statement can only read one string.

    3.Operations on strings (brought by pascal):

    length(s)

    Function. Find the length of the string s.

    The return value is integer.

    s:='123456789';

    l:=length(s);

    copy(s,w,k)

    Function. Copy the k bits starting from w in s.

    The return value is a character.

    s:='123456789';

    s1:=copy(s,3,5);

    val(s,k,code)

    Process. Convert the string s to a numeric value and store it in k; code is an error ** (generally do not consider using val(s,k)).

    s:='1234';

    val(s,k);

    str(i,s)

    Process. Convert the value i to the string s

    i:=1234;

    str(i,s);

    delete(s,w,k)

    Process. Remove k characters starting from the wth bit in s.

    s:=honest

    abelincoln';

    delete(s,8,4);

    Operator. Concatenate the two strings.

    s1:='1234';s2:='5678';

    s:=s1+s2;

  4. Anonymous users2024-02-02

    program

    ex8_5;

    vars1,s,o:string;

    i:integer;

    beginwrite('the

    text:');

    readln(s1);

    write('find:');readln(s);

    write('replace:');readln(o);

    i:=pos(s,s1);

    whilei<>0

    dobegin

    delete(s1,i,length(s));

    insert(o,s1,i);

    i:=pos(s,s1);

    end;writeln(s1);

    readln;

    end.1. Definition of String.

    A string is an infinite sequence of characters, defined by the string type:

    typeString type identifier》=string[n];

    var string variable: string type identifier;

    Wherein: n is the defined string length, which must be a natural integer between 0 255, the actual length of the string is stored in unit 0, which is automatically provided by the system when the program runs, and the characters of the string are stored in unit 1 n, if string[n] is written as string, the default n value is 255.

    For example: type

    man=string[8];

    line=string;

    varname:man;

    screenline:line;

    Another way to define a character type is to combine the variable definitions of the type description.

    For example: var

    name:string[8];

    screenline:string;

    In TurboPascal, characters in a string can be flexibly used by their corresponding subscripts.

    For example: var

    name:string;

    beginreadln(name);

    fori:=1

    toord(name[0])

    dowriteln(name[i]);

    end.

Related questions
5 answers2024-02-09

98. In the system, click "Start--Run", enter "msconfig", click "Advanced" in "System Utility Configurator", select "Disable Rapid Shutdown", and restart. >>>More

9 answers2024-02-09

I] do have a lot of 1Peer Junior - nae na 2Elder - ze zea

The karma you said is a particle, and it is added at the same time in different situations. >>>More

24 answers2024-02-09

I'm not a master, I'm just an amateur! If you are not a professional athlete, you don't have to be too obsessed with shooting movements, including professional athletes, there are many people whose postures are very non-standard, just find the posture that you think is most suitable for you. >>>More

13 answers2024-02-09

After deciding to use wood flooring as a floor decoration material, you must follow the following steps to purchase: Before purchasing, you must first know the level, orientation and area of your residence, and it is best to draw a floor plan for overall planning, specifically allocate the use functions of each room, and then choose the floor according to local conditions; Generally speaking, young people are busy with work and study, so it is impossible to be completely consistent with the requirements of the elderly and children. It is also necessary to consider the performance of the floor, whether it is temporary or long-term, and whether it will cause operation and damage to the surrounding buildings during the paving construction; Finally, you should also consider your own financial ability and budget for decoration costs. The disadvantage of laminate flooring is that when laying a large area, there will be the phenomenon of overall arching and deformation. >>>More

4 answers2024-02-09

Landlord, hello, I don't know if the following methods can be solved, but you don't want to try. >>>More