, . : <> < > [ <- > ];
: int arr[50];
int arr 50- .
: float myTestArrayForLesson[10 * 1000 + 1];
. :
int arr[] = {0, 1, 2, 3, 4, 5}; // 6 ( 0 5) int mas[100] = {0}; // 100 0 |
, , , .
, .
! C++ . 1, 9. , .
, . , : arr[6] = 7 * 4; // arr[6] 28
C++ :
< > < > [ < > ] < > |
: cout << arr[10] << ", " << arr[11] << endl;
.
, . . ( ) . . : int arr[100][50] = {0}; //
100×50, . :
int matrix[100][100] = {0}; matrix[5][10] = 11; matrix[10][5] = 1; cout << "Interesting values:\n"; cout << matrix[0][0] << ", " << matrix[5][10] << ", " << matrix[10][5] << endl; |
( main), :
Interesting values:
0, 11, 1
Process returned 0 (0×0) execution time: 0.020 s
Press any key to continue.
, . , .
|
|
. ( ). ( , ).
:
#include <iostream> #include <stdlib.h> using namespace std; int main() { int data[500][500] = {0}; // string type; // int x, y, val; while (true) { // cin >> type; // if (type == "End") { // End, break; } else if (type == "Insert") { // cin >> x >> y >> val; data[x][y] = val; } else if (type == "Delete") { // cin >> x >> y; data[x][y] = 0; } else if (type == "Get") { // cin >> x >> y; cout << data[x][y] << endl; } else { // - cout << "Error! Let's try again." << endl; } } cout << "\nOk. Good work." << endl; return 0; } |
:
Insert 1 1 4
Insert 5 4 2
Inser
Error! Let's try again.
Get 1 2
Get 5 4
Get 1 1
Delete 1 1
Get 1 1
End
Ok. Good work.
Process returned 0 (0×0) execution time: 0.020 s
Press any key to continue.
:
1. , - (: bool).
2. x y. x >= 500. x y.