#define < > <> /* , C */ |
#define PI 3.14159
. # (;).
. , , . , , . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// /* () */ | { ( Pascal) } (* . (Object Pascal Delphi) *) // . (Object Pascal) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
, . , . . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
C++
| Pascal
| Basic
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(. statement) ; . . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
; | ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
, , , . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
C++
| Pascal
| Basic Basic . . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
. - . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
var1 = 20; var2 = var1+10; |
var1 := 20; var2 := var1+10; |
var1 = 20 var2 = var1+10 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
. , . . . , , , . , . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
, () . - . | |||||||
if
if ( a>10 ) a=1; if ( a<10 ) a=11; else a=1; if ( a==10 ) { a=1; b=2 ;} if ( a<>10 ) { a=2; b=1 ;}else{ a=1; b=2 ;} | if
if a>10 then a:=1;
if a<10 then a:=11 else a:=1; if a=10 thenbegin a:=1; b:=2 end; if a<>10 thenbegin a:=2; b:=1 end else begin a:=1; b:=2 end; | if
If a>10 Then a=1 If a<10 Then a=11 Else a=1 If a=10 Then a=1 b=2 End If If a<>10 Then a=2 b=1 Else a=1 b=2 End If |
switch
switch ( 2*2 ) { case 1: n=1; case 2: n=2; case 3: n=3; default: n=4; }
case , . case . Break . | case
Case (2*2) of 1: n:=1; 2: n:=2; 3: n:=3; else: n:=4; end;
Case . | select
Select Case 2*2 Case 1: n=1 Case 2: n=2 Case 3: n=3 Case Else: n=4 End Select
Case , . |
, . , , . . , , , ( , ). , , . , , (, ), . . , : 1 , 2 , 3 . . : 1. ( ) . - . 2. , , . , ( ). - . 3. , . , . - . | |||||||
C++ ( )
for ( j=0; j<15; j++ ) n++;
for ( j=0; j<15; j++ ) { n++; k-- ;} for ( j=0, i=1; j<15; j++, i-- ) n++; | Pascal ( )
for j := 0 to 15 do n:=n+1; for j := 15 downto 0 do n:=n+1; for j := 0 to 15 do begin n:=n+1 end; | Basic
For j = 0 To 15 n=n+1 Next j |
C++
while ( j<15 ) j++; | Pascal
while i<=100 do | Basic
Do While i<10 s=s+i i=i+1 Loop | |||
C++
do { s=s+i; i-- ;} while ( i>10 ) | Pascal
repeat s:=s+i; i:=i-1 until i>10; | Basic
Do s=s+i i=i-1 Loop Until i>10 | |||
. . , . , . . . , 10 , 10 , 100 1000 . : 1 , 2 , . |
|
|
C++ break;/* break, , ( switch) */ continue;/* */ goto<>;/* */ | Pascal break;{ break, , } continue;{ } goto<>;{ } | Basic Exit For/Do Exit For/Do, , GoTo<> | |||
/ . - . , . | |||||
C++
#include <iostream> using namespace std; void main() { int ftemp; cin>> ftemp } | Pascal
Read( i ); ReadLn( i,j ); | Basic
I= InputBox( , , 10 ) |
C++
#include <iostream> using namespace std; void main() { cout << . << endl; } | Pascal
Write( a= ); ReadLn( a ); WriteLn( , a ); | Basic
MsgBox( & a ) |
C++
:
1. ()
cout << A << \t << B;
2. #include <iomanip>
cout << setw(9) << << endl;
3. printf, sprintf | Pascal
Write(A=,< >);
Write(A=, A:9:5); | Basic MsgBox(Format(<>|<>[, < >]) MyStr = Format(23) ' "23". MyStr = Format(5459.4, "##,##0.00") ' "5,459.40". MyStr = Format(334.9, "###0.00") ' "334.90". MyStr = Format(5, "0.00%") ' "500.00%". MyStr = Format("HELLO", "<") ' "hello". MyStr = Format("This is it", ">") ' "THIS IS IT". Format . , . |
C++
#include <iostream> using namespace std; int main() { int s=0,i=1; while (i<=100) { s+=i; i++; } cout << s; return s; } | Pascal
: Pascal , program < >; , .
Uses, Label, Const, Type, Var, Procedure, Function , , ;.
Program XXX; Var s,i: integer; Begin s:=0; i:=1; while i<=100 do begin s:=s+i; i:=i+1 end; writeln(s=;s:5) End. | Basic
Exit Sub .
Sub XXX Dim s As integer Dim i As integer s=0 i=1 Do While i<=100 s=s+i i=i+1 Loop MsgBox(s= & s) End Sub |
C++ <cstdlib> : atoll, atoi, atof. : yourDouble=atof(23dfg); yourInt=atoi(fd234); yourLong=atol(fdgb33d); <sstream> stringstream. : #include <iostream> #include <sstream> #include <string> using namespace std; int main(){ string s=100; int a; stringstream conv; conv << s; conv >> a; conv.clear(); } | Pascal Val . : Val(<>,< >,< >); , . . : 0-9, +, -,., E Val(23 sdf,A,cod) {A=0, Cod=4} | Basic Val . : < > = Val(<>) . , . : 0-9, +, -,., E A=Val(23 sdf sdf) 23 |
, . - . : 1. - , ; 2. - , . : 1. ; 2. . , . - , , . / , . /, . , , . . : 1. , 2. , , . . |
- C++
() , . , . . . Ũ !
( ) . , .
#include <iostream> using namespace std; void starline(); intmain(){ starline(); return s; } void starline() { for(int j=0; j<45; j++) cout << *; cout << endl; }
#include <iostream> using namespace std; void starline() { for(int j=0; j<45; j++) cout << *; cout << endl; } intmain(){ starline(); return s; } | - Pascal
Ũ !
Program Pr; Var a,b: integer; Function summ(a,b: integer): integer; Begin summ:=a+b; end; Begin Read(a,b); Write(summ(a,b)); End. | - Basic
: 2017-02-11; !; : 510 | : : , , . |