Summ=a+b
End Function
Sub Pr
Dim a, b
a=InputBox( A)
b=InputBox( B)
MsgBox(Summ(a,b))
End Sub
, , . (). : 1. ; 2. . | ||
C++ < > < > [< >] < > < > [< >][< >] int age[4]; int age[4]={21,12,3,23,1}; int ege[2][3]; int ege[2][3]={{1,2,3},{4,5,6}}; 0. < >[<>] < >[<>][<>] age[3] ege[2][1] | Pascal Var < >: array [<. >..<. >] of < > Var < >: array [<. >..<. >[, <. >..<. >]] of < > Var a: array [1..10] of integer; Var a: array [10] of integer; Var b: array [1..10,1..5] of real; Var b: array [10, 5] of real; 1. < >[<>] < >[<>,<>] a[5] b[3,4] | Basic Dim < > (<. > To <. >) [As < >] Dim < > (<. > To <. > [,<. > To <. >]) [As < >] Dim A(1 To 10) As Integer Dim A(10) As Integer Dim B(1 To 10, 1 To 5) As Single Dim B(10, 5) As Single 0. Option Base 1 1. < >(<>) < >(<>,<>) A(5) B(3,4) Dim < >() [As <>] ReDim < >(<. ->) Dim A() As Integer ReDim A(5) |
|
|
, (. bubble sort) . . , , . , , , . , , , , . | ||
C++ for(i=1;i<=n-1;i++) for(j=i+1;j<=n;j++) If(arr[j]<arr[i]) { tmp=arr[j]; arr[j]=arr[i]; arr[i]=tmp; } | Pascal for i:=1 to n-1 do for j:=i+1 to n do if arr[j]<arr[i] then begin tmp:=arr[j]; arr[j]:=arr[i]; arr[i]:=tmp; end; | Basic For i=1 To n-1 For j=i+1 To n If arr(j)<arr(i) Then tmp=arr(j) arr(j)=arr(i) arr(i)=tmp End If Next j Next i |
(, . Pseudorandom number generator, PRNG) , , ( ). | ||
C++ # include <cstdlib> # include <ctime> srand(time(NULL)); /* */ k = rand() % 52; /* 0 51 */ | Pascal Randomize; { } k:=Random; { 0<=x<1 } k:=Random(n); { 0<=x<n } | Basic Randomize k=RND 0<=x<1 |
C++ : / MyValue=8/3 // 2 : % MyValue=8%3 // 2 | Pascal : div MyValue:=15 div 3 { 5 } : mod MyValue:=15 mod 3 { 0 } | Basic : \ MyValue=11\4 2 : mod MyValue=11 mod 4 3 |
|
|
. | ||
C++ # include <string> // string var1; // | Pascal String { } String[N] { } | Basic String String*N |
C++ < >.substr(<>,<->) substr() s=; x=s.substr(2,2); // < >.find(<>) find() s=; x=s.find(); // 3 < >.length() length() s=; x=s.length(); // 6 strcat(< 1>, < 2>) strcat 2 1 strcat(,); // +. x= + ; // < >.append(<->,<>) append() s=; x=s.append(1,!); // ! < >.erase(<>,<->) erase() s=; x=s.erase(2,2); // (int)< > - char int s=b; x=(int)s; // 98 (char)< > - int char s=98; x=(char)s; // b (string)<> - string s=98; x=(string)s; // b | Pascal Copy(<>,<>,<->) Copy X:=Copy(,3,4); { } Pos(<>,<>) - Pos X:=Pos(,); { 4 } Length(<>) Length X:=Length(); { 6 } Concat(<1>,<2>,..) Concat X:=Concat(,); { } +. X:= + ; { } Insert(<2>,< >, <>) Insert 1 Insert(,,3); {} Delete(< >,<>,<->) Delete Delete(,2,2); { } Ord(<>) Ord ASCII X:=Ord(b); { 98 } Chr(< >) Chr ASCII X:=Chr(98); { b } Str(<>, < >) Str . Str(98,X); { 98 } | Basic Mid(<>,<>,<->) Mid X=Mid(,3,4) InStr([],<>, <>) InStr X=InStr(1,,) 4 Len(<>) Length X=Len() 6 Basic + &. X= + X= & Asc(<>) Asc ASCII X=Ord(b) 98 Chr(< >) Chr ASCII X=Chr(98) b Str(<>) Str . X=Str(98) 98 |
|
|
, . : 1. , 2. . , . , (CR) (LF). 32 255, 32 : 08 (BS) , 09 (TAB) , 0A (LF) , 0C (FF) , 0D (CR) , 1A (EOF) . , . , , / . , , . , . , . | ||
C++ , . Struct < >{ < > < >; < > < >; < > < >; }; Struct Stud{ string FIO; string Gr; byte KD; }; C++, . , . (). Stud S; cout << S.FIO; fstream: #include <fstream> fstream. open(): fstream file; file.open(QWE.TXT, ios::app | ios:out | ios::in); /* , : in , out , ate , app , trunc , , binary ( */ eof(): while(!file.eof()){ }; /* */ close(): file.close(); / : >>, <<, get(), put(), read(), write(), getline(): file.get(ch); // file.put(ch); // file.read(reinterpret_cast<char*> (&<>), sizeof(<>)); /* */ file.write(reinterpret_cast<char*> (&<>), sizeof(<>)); /* */ file.getline(<>, < >); /* ( \n)*/ : seekg(< >, ios::beg); /* . beg , end cur */ tellg(); /* */ | Pascal Record , . Type < > = Record < >: < >; < >: < >; < >: < >; end; Type Stud = Record FIO: string[45]; Gr: string[6]; DB: string[8]; KD: byte; end; Pascal, . , . (). Var S: Stud; Write(S.FIO); . : Var < . .>: file of < >; . : Var < . .>: Text; : Assign(< >, ); { } Reset(< >); { , } Rewrite(< >); { / } Read(< >, <>); { } Write(< >, <>); { } Close(< >); { } Erase(< >); { } Rename(< >,< >); { } EoF(< >); { true } : Seek(< >, <>); { } FilePos(< >); { } FileSize(< >); { } | Basic , . Type < > < > As < > < > As < > < > As < > End Type Type Stud FIO As String Gr As String DB As String KD As Byte End Type Basic, . , . (). Dim S As Stud MsgBox(S.FIO) : Open "< >" For Input As #< > FreeFile ( 1 511) : FileNum = FreeFile Line Input . Line Input #< >, <> EOF(< >) true . Close #< > Open "< >" For Output As #< > Print . Print #< >, <> |
|
|
|
|
|
|
: 2017-02-11; !; : 470 |
:
, , 1:10
==> ...