-
1.Read in two data, A and B, and output them one by one. The first a b should refer to the divisibility of a b, and then the decimal division is the division with decimals, that is, the ordinary division.
Procedure vara, b: integer;
beginreadln(a,b);
writeln(a,'+',b,'=',a+b);
writeln(a,'-',b,'=',a-b);
writeln(a,'*',b,'=',a*b);
writeln(a,'/',b,'=',a div b);
writeln(a,'/',b,'=',a/b:2:2);
writeln(a,'/',b,'=',a div b,'...',a mod b);
readln;
end.2.First, read this character, use the pred() function to find the precursor character, use the succ() function to find the subsequent characters, and then compare their ASQII code values, and output them from large to small.
Procedure: var
a:char;
beginreadln(a);
write(pred(a),' ',a,' ',succ(a));
readln;
-
For example, a is equal to 10, b is equal to 5, and the result of a + b is 10 + 5 = 15
vara,b,s:real;
beginread(a,b);
s:=a+b;
write("a+b=",s);end
-
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.
-
If you find the first one that matches, execute the then following statement, and then skip to the next semicolon to continue.
-
(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".
-
vara,i,n,k:longint;
beginread(n);
a:=1;i:=1;
repeat
inc(i);
a:=a*2;
k:=k+a;
until i=n;
writeln(k);
end.Any questions you can ask me.
-
The method downstairs is good, but can you really understand it?
Let me explain:
1.First of all, put 1 grain of wheat in the first grid, 1 >> 1
In the second compartment put 2 grains of wheat, 2 >> 2
In the third compartment put 4 grains of wheat, 3 >> 4
Put 2 (n-1) grains of wheat in the nth lot.
Can this be done?
2.The next thing we need to do is to calculate how to design the algorithm output 2 (n-1) for the input n. The first thing that comes to mind is this:
var i,n,s:longint;
beginreadln(n);
s:=1;for i:=1 to n-1 do
s:=s*2;
writeln(s);
end.But! Longint can only store the number of -2147483648 to 2147483647 (i.e. -2 31 to 2 31-1), and the maximum calculation is 2 30, which does not meet the conditions of the problem, we say with high precision, which is a solution.
For the storage scope of various data types in Pascal, see:
Please look at the ** of the one downstairs, it is very short, but it is actually very efficient, and it is suitable for this question. Why?
ta uses qword type, paraphrase on encyclopedia:
-
Let's start with the idea.
Look for it from the beginning of the string.
3: Repeat 1 and 2, compare the length of the substring to get the new maximum length value, and modify the content of the source base and the longest substring of the starting value.
The specific implementation of the program will be given later.
-
I don't know if lz knows that bit operations are not. If you don't know, just search the encyclopedia.
For example, the binary of 6 is 110, and the right two digits are 1, that is, 6 shr 2=1, a[n+1]:=maxlongint>>2; That's what it means.
a[n+1]:=maxlongint shr 2;Actually, this can also be thought of as a[n+1]:=maxlongint div 2 div 2; It's just that the efficiency of bit operations is very high.
-
maxlongint is the maximum value of longint, that is, 2 31-1, >>2 and shr 2 or div 4 are the same function, these 4 sentences are to assign the values of 1 n, n+1 and n+2 of the b array to (2 31-1) div 4
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. >>>More
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
Simple pacal compiler implementation. rar] - This source code is a simple Pascal compiler implementation, implemented with the tools lex and yacc. >>>More
Refer to the upstairs, but upstairs doesn't know then without adding a statement? >>>More
Hotkey. Registration (Tab 1.)Take the window handle ()0, F1, > register F1 >>>More