STL , . . , STL (, - , ), . . , :
#include "stdafx.h"
#include <iostream>
#include <list>
#include <deque>
#include <algorithm>
using namespace std;
/* , .
* , ,
* CountedPtr
* .
*/
template <class T>
class CountedPtr {
private:
T* ptr; //
long* count; // ( )
public:
//
// - p new
explicit CountedPtr(T* p = 0)
: ptr(p), count(new long(1)) {
}
// ( )
CountedPtr(const CountedPtr<T>& p) throw()
: ptr(p.ptr), count(p.count) {
++*count;
}
// ( , )
~CountedPtr() throw() {
dispose();
}
// ( )
CountedPtr<T>& operator= (const CountedPtr<T>& p) throw() {
if (this!= &p) {
dispose();
ptr = p.ptr;
count = p.count;
++*count;
}
return *this;
}
// ,
T& operator*() const throw() {
return *ptr;
}
T* operator->() const throw() {
return ptr;
}
private:
void dispose() {
if (--*count == 0) {
delete count;
delete ptr;
}
}
};
, , , new. CountedPtr , . , .
CountedPtr , .
CountedPtr:
void printCountedPtr(CountedPtr<int> elem)
{
cout << *elem << ' ';
|
|
}
int main()
{
// (
// )
static int values[] = { 3, 5, 9, 1, 6, 4 };
//
typedef CountedPtr<int> IntPtr;
deque<IntPtr> coll1;
list<IntPtr> coll2;
/*
* - coll1
* - coll2
*/
for (int i = 0; i<sizeof(values) / sizeof(values[0]); ++i) {
IntPtr ptr(new int(values[i]));
coll1.push_back(ptr);
coll2.push_front(ptr);
}
//
for_each(coll1.begin(),coll1.end(),printCountedPtr);
cout << endl;
for_each(coll2.begin(), coll2.end(),printCountedPtr);
cout << endl << endl;
/*
* - coll1
* - coll1
* - coll2
*/
*coll1[2] *= *coll1[2];
(**coll1.begin()) *= -1;
(**coll2.begin()) = 0;
//
for_each(coll1.begin(), coll1.end(),printCountedPtr);
cout << endl;
for_each(coll2.begin(), coll2.end(),printCountedPtr);
cout << endl;
}
:
3 5 9 1 6 4
4 6 1 9 5 3
-3 5 81 1 6 0
0 6 1 81 5 -3
, (IntPtr) - , , , .
Boost C++ (http://www.boost.org/) , C++.
1. .. ++: . - 5- . - .: , 2000. - 560. .
2. . . ++ . - .: , 1996. - 272.
3. ++. 3- . /. . - .; .: - ̻, 1999. - 991. .
4. . . 3- .: . .: .. - .: "", 2000. - ., .
5. ., . : . . .: , 1988. 560 . .
1
ASCII
1.1
(0 - 31)
10 | 08 | 16 | |||
nul | 0 | 0 | 00 | ^@ | |
soh | 1 | 1 | 01 | ^A | |
stx | 2 | 2 | 02 | ^B | |
etx | 3 | 3 | 03 | ^C | |
eot | 4 | 4 | 04 | ^D | |
enq | 5 | 5 | 05 | ^E | |
ack | 6 | 6 | 06 | ^F | |
bel | 7 | 7 | 07 | ^G | () |
bs | 8 | 10 | 08 | ^H | ( ) |
ht | 9 | 11 | 09 | ^I | |
lf | 10 | 12 | 0 | ^J | |
vt | 11 | 13 | 0B | ^K | |
ff | 12 | 14 | 0 | ^L | |
cr | 13 | 15 | 0D | ^M | |
so | 14 | 16 | 0 | ^N | |
si | 15 | 17 | 0F | ^O | |
dle | 16 | 20 | 10 | ^P | |
dc1 | 17 | 21 | 11 | ^Q | 1 |
dc2 | 18 | 22 | 12 | ^R | 2 |
dc3 | 19 | 23 | 13 | ^S | 3 |
dc4 | 20 | 24 | 14 | ^T | 4 |
nak | 21 | 25 | 15 | ^U | |
syn | 22 | 26 | 16 | ^V | |
etb | 23 | 27 | 17 | ^W | |
can | 24 | 30 | 18 | ^X | |
em | 25 | 31 | 19 | ^Y | |
sub | 26 | 32 | 1 | ^Z | |
esc | 27 | 33 | 1B | ^ [ | |
fs | 28 | 34 | 1 | ^ \ | |
gs | 29 | 35 | 1D | ^ ] | |
rs | 30 | 36 | 1E | ^ ^ | |
us | 31 | 37 | 1F | ^_ |
"" ^ Ctrl, "" , .
|
|
1.2
32 127
10 | 08 | 16 | 10 | 08 | 16 | |||
32 | 40 | 20 | = | 61 | 75 | 3D | ||
! | 33 | 41 | 21 | > | 62 | 76 | ||
" | 34 | 42 | 22 | ? | 63 | 77 | 3F | |
# | 35 | 43 | 23 | @ | 64 | 100 | 40 | |
$ | 36 | 44 | 24 | 65 | 101 | 41 | ||
% | 37 | 45 | 25 | 66 | 102 | 42 | ||
£ | 38 | 46 | 26 | 67 | 103 | 43 | ||
' | 39 | 47 | 27 | D | 68 | 104 | 44 | |
( | 40 | 50 | 28 | 69 | 105 | 45 | ||
) | 41 | 51 | 29 | F | 70 | 106 | 46 | |
* | 42 | 52 | 2 | G | 71 | 107 | 47 | |
+ | 43 | 53 | 2 | 72 | 108 | 48 | ||
, | 44 | 54 | 2C | I | 73 | 111 | 49 | |
- | 45 | 55 | 2D | J | 74 | 112 | 4A | |
. | 46 | 56 | 2 | K | 75 | 113. | 4B | |
/ | 47 | 57 | 2F | L | 76 | 114 | 4C | |
0 | 48 | 60 | 30 | 77 | 115 | 4D | ||
1 | 49 | 61 | 31 | N | 78 | 116 | 4E | |
2 | 50 | 62 | 32 | 79 | 117 | 4F | ||
3 | 51 | 63 | 33 | 80 | 120 | 50 | ||
4 | 52 | 64 | 34 | Q | 81 | 121 | 51 | |
5 | 53 | 65 | 35 | R | 82 | 122 | 52 | |
6 | 54 | 66 | 36 | S | 83 | 123 | 53 | |
7 | 55 | 67 | 37 | 84 | 124 | 54 | ||
8 | 56 | 70 | 38 | U | 85 | 125 | 55 | |
9 | 57 | 71 | 39 | V | 86 | 126 | 56 | |
: | 58 | 72 | W | 87 | 127 | 57 | ||
; | 59 | 73 | X | 88 | 130 | 58 | ||
< | 60 | 74 | Y | 89 | 131 | 59 | ||
Z | 90 | 132 | 5A | m | 109 | 155 | 6D | |
[ | 91 | 133 | 5B | n | 110 | 156 | 6E | |
\ | 92 | 134 | 5C | 111 | 157 | 6F | ||
] | 93 | 135 | 5D | p | 112 | 160 | 70 | |
^ | 94 | 136 | 5E | q | 113 | 161 | 71 | |
_ | 95 | 137 | 5F | 114 | 162 | 72 | ||
` | 96 | 140 | 60 | s | 115 | 163 | 73 | |
a | 97 | 141 | 61 | t | 116 | 164 | 74 | |
b | 98 | 142 | 62 | u | 117 | 165 | 75 | |
c | 99 | 143 | 63 | v | 118 | 166 | 76 | |
d | 100 | 144 | 64 | w | 119 | 167 | 77 | |
e | 101 | 145 | 65 | x | 120 | 170 | 78 | |
f | 102 | 146 | 66 | Y | 121 | 171 | 79 | |
g | 103 | 147 | 67 | z | 122 | 172 | 7 | |
h | 104 | 150 | 68 | { | 123 | 173 | 7 | |
i | 105 | 151 | 69 | | | 124 | 174 | 7 | |
j | 106 | 152 | 6A | } | 125 | 175 | 7D | |
k | 107 | 153 | 6B | ~ | 126 | 176 | 7 | |
1 | 108 | 154 | 6C | del | 127 | 177 | 7F |
1.3
128 - 255 ( 866 - MS-DOS)
10 | 08 | 16 | 10 | 08 | 16 | |||
128 | 200 | 80 | 156 | 234 | 9 | |||
129 | 201 | 81 | 157 | 235 | 9D | |||
130 | 202 | 82 | 158 | 236 | 9 | |||
131 | 203 | 83 | 159 | 237 | 9F | |||
132 | 204 | 84 | 160 | 240 | ||||
133 | 205 | 85 | 161 | 241 | 1 | |||
134 | 206 | 86 | 162 | 242 | 2 | |||
135 | 207 | 87 | 163 | 243 | A3 | |||
136 | 210 | 88 | 164 | 244 | 4 | |||
137 | 211 | 89 | 165 | 245 | 5 | |||
138 | 212 | 8 | 166 | 246 | 6 | |||
139 | 213 | 8 | 167 | 247 | 7 | |||
140 | 214 | 8 | 168 | 250 | 8 | |||
141 | 215 | 8D | 169 | 251 | 9 | |||
142 | 216 | 8 | 170 | 252 | ||||
143 | 217 | 8F | 171 | 253 | ||||
144 | 220 | 90 | 172 | 254 | ||||
145 | 221 | 91 | 173 | 255 | AD | |||
146 | 222 | 92 | 174 | 256 | ||||
147 | 223 | 93 | 175 | 257 | AF | |||
148 | 224 | 94 | ░ | 176 | 260 | |||
X | 149 | 225 | 95 | ▒ | 177 | 261 | 1 | |
150 | 226 | 96 | ▓ | 178 | 262 | 2 | ||
151 | 227 | 97 | | | 179 | 263 | |||
152 | 230 | 98 | ┤ | 180 | 264 | 4 | ||
153 | 231 | 99 | ╡ | 181 | 265 | 5 | ||
154 | 232 | 9 | ╢ | 182 | 266 | 6 | ||
155 | 233 | 9 | ╖ | 183 | 267 | 7 | ||
╕ | 184 | 270 | 8 | ╓ | 214 | 326 | D6 | |
╣ | 185 | 271 | 9 | ╫ | 215 | 327 | D7 | |
║ | 186 | 272 | ╪ | 216 | 330 | D8 | ||
╗ | 187 | 273 | ┘ | 217 | 331 | D9 | ||
╝ | 188 | 274 | ┌ | 218 | 332 | DA | ||
╜ | 189 | 275 | BD | █ | 219 | 333 | DB | |
╛ | 190 | 276 | BE | ▄ | 220 | 334 | DC | |
┐ | 191 | 277 | BF | ▌ | 221 | 335 | DD | |
└ | 192 | 300 | ▐ | 222 | 336 | DE | ||
┴ | 193 | 301 | 1 | ▀ | 223 | 337 | DF | |
┬ | 194 | 302 | 2 | 224 | 340 | |||
├ | 195 | 303 | 225 | 341 | 1 | |||
196 | 304 | 4 | 226 | 342 | 2 | |||
+ | 197 | 305 | 5 | 227 | 343 | |||
╞ | 198 | 306 | 6 | 228 | 344 | 4 | ||
╟ | 199 | 307 | 7 | X | 229 | 345 | 5 | |
╚ | 200 | 310 | 8 | 230 | 346 | 6 | ||
╔ | 201 | 311 | 9 | 231 | 347 | 7 | ||
╩ | 202 | 312 | 232 | 350 | 8 | |||
╦ | 203 | 313 | 233 | 351 | 9 | |||
╠ | 204 | 314 | 234 | 352 | ||||
═ | 205 | 315 | CD | : | 235 | 353 | ||
╬ | 206 | 316 | 236 | 354 | ||||
╧ | 207 | 317 | CF | 237 | 355 | ED | ||
╨ | 208 | 320 | DO | 238 | 356 | |||
╤ | 209 | 321 | D1 | 239 | 357 | EF | ||
╥ | 210 | 322 | D2 | ≡ | 240 | 360 | F0 | |
╙ | 211 | 323 | D3 | 241 | 361 | F1 | ||
╘ | 212 | 324 | D4 | ≥ | 242 | 362 | F2 | |
╒ | 213 | 325 | D5 | ≤ | 243 | 363 | F3 | |
⌠ | 244 | 364 | F4 | . | 250 | 372 | FA | |
⌡ | 245 | 365 | F5 | √ | 251 | 373 | FB | |
÷ | 246 | 366 | F6 | n | 252 | 374 | FC | |
≈ | 247 | 367 | F7 | z | 253 | 375 | FD | |
248 | 370 | F8 | ■ | 254 | 376 | FE | ||
● | 249 | 371 | F9 | 255 | 377 | FF |
|
|
1.4
128 - 255 ( 1251 MS Windows)
10 | 08 | 16 | 10 | 08 | 16 | |||
128 | 200 | 80 | ״ | 148 | 224 | 94 | ||
129 | 201 | 81 | 149 | 225 | 95 | |||
, | 130 | 202 | 82 | - | 150 | 226 | 96 | |
131 | 203 | 83 | 151 | 227 | 97 | |||
,, | 132 | 204 | 84 | □ | 152 | 230 | 98 | |
133 | 205 | 85 | 153 | 231 | 99 | |||
134 | 206 | 86 | 154 | 232 | 9 | |||
≠ | 135 | 207 | 87 | > | 155 | 233 | 9 | |
□ | 136 | 210 | 88 | 156 | 234 | 9 | ||
137 | 211 | 89 | 157 | 235 | 9D | |||
138 | 212 | 8 | 158 | 236 | 9 | |||
< | 139 | 213 | 8 | 159 | 237 | 9F | ||
140 | 214 | 8 | 160 | 240 | ||||
141 | 215 | 8D | 161 | 241 | 1 | |||
142 | 216 | 8 | 162 | 242 | 2 | |||
143 | 217 | 8F | J | 163 | 243 | A3 | ||
Ŋ | 144 | 220 | 90 | 164 | 244 | 4 | ||
` | 145 | 221 | 91 | 165 | 245 | 5 | ||
' | 146 | 222 | 92 | 166 | 246 | 6 | ||
`` | 147 | 223 | 93 | 167 | 247 | 7 | ||
168 | 250 | 8 | 3 | 199 | 307 | 7 | ||
169 | 251 | 9 | 200 | 310 | 8 | |||
170 | 252 | 201 | 311 | 9 | ||||
171 | 253 | 202 | 312 | |||||
172 | 254 | 203 | 313 | |||||
- | 173 | 255 | AD | 204 | 314 | |||
174 | 256 | 205 | 315 | CD | ||||
175 | 257 | AF | 206 | 316 | ||||
176 | 260 | 0 | 207 | 317 | CF | |||
177 | 261 | 1 | 208 | 320 | D0 | |||
178 | 262 | 2 | 209 | 321 | D1 | |||
179 | 263 | 210 | 322 | D2 | ||||
180 | 264 | 4 | 211 | 323 | D3 | |||
μ | 181 | 265 | 5 | 212 | 324 | D4 | ||
182 | 266 | 6 | X | 213 | 325 | D5 | ||
. | 183 | 267 | 7 | 214 | 326 | D6 | ||
184 | 270 | 8 | 215 | 327 | D7 | |||
??? | 185 | 271 | 9 | 216 | 330 | D8 | ||
186 | 272 | 217 | 331 | D9 | ||||
187 | 273 | 218 | 332 | DA | ||||
j | 188 | 274 | 219 | 333 | DB | |||
S | 189 | 275 | BD | 220 | 334 | DC | ||
s | 190 | 276 | BE | 221 | 335 | DD | ||
ï | 191 | 277 | BF | 222 | 336 | DE | ||
192 | 300 | 0 | 223 | 337 | DF | |||
193 | 301 | C1 | 224 | 340 | 0 | |||
194 | 302 | 2 | 225 | 341 | 1 | |||
195 | 303 | 226 | 342 | 2 | ||||
196 | 304 | 4 | 227 | 343 | ||||
197 | 305 | 5 | 228 | 344 | 4 | |||
198 | 306 | 6 | 229 | 345 | 5 | |||
230 | 346 | 6 | 243 | 363 | F3 | |||
231 | 347 | 7 | 244 | 364 | F4 | |||
232 | 350 | 8 | 245 | 365 | F5 | |||
233 | 351 | 9 | 246 | 366 | F6 | |||
234 | 352 | 247 | 367 | F7 | ||||
235 | 353 | 248 | 370 | F8 | ||||
236 | 354 | 249 | 371 | F9 | ||||
237 | 355 | ED | 250 | 372 | FA | |||
238 | 356 | 251 | 373 | FB | ||||
239 | 357 | EF | 252 | 374 | FC | |||
240 | 360 | F0 | 253 | 375 | FD | |||
241 | 361 | F1 | 254 | 376 | FE | |||
242 | 362 | F2 | 255 | 377 | FF |
|
|
2
2.1
- math. h
Abs | int abs(int i); I |
Acos | double s (double ); . -1 +1 |
Asin | double asin(double ); . -1 +1 |
atan | double atan(double x); |
atan2 | double atan2(double , double ); / |
cabs | double cabs(struct complex znum); znum. () complex - math.h |
cos | double cos(double x); . () |
cosh | double cosh (double x); |
exp | double exp(double x); x ( ) |
fabs | double fabs(double x); |
floor | double floor(double x); , . double |
fmod | double fmod(double x, double y); |
hypot | double hypot(double x, double ); z , (z2 = 2 + 2) |
labs | long labs(long ); long x |
ldexp | double ldexp(double v, int e); v2e |
log | double log(double x); (In x) |
log10 | double log10(double x); (log10 ) |
poly | double poly(double x, int n, double c[ ]); : c[n]xn + c[n - 1]n-1 +... + c[l]x + c[0] |
pow | double pow(double x, double ); xy, .. |
pow10 | double pow10(int p); 10p |
sin | double sin(double x); . () |
sinh | double sinh(double x); |
sqrt | double sqrt(double x); |
tan | double tan(double x); . () |
tanh | double tanh(double x); |
2.2
|
|
- ctype. h
isalnum | int isalnum(int ); , - ( - z, a - z,0 - 9), - |
isalpha | int isalpha(int ); , - ( - Z, - z), - |
isascii | int isascii(int ); , ASCII, .. 0 127, |
iscntrl | int iscntrl(int ); , - 0x00 - 0x0lF 0x7F, - |
isdigit | int isdigit(int ); , - (0 - 9) ASCII, - |
isgraph | int isgraph(int ); , - () (0x21 - 07), - |
islower | int islower(int ); , - ( - z), - |
isprint | int isprint(int ); , - (0x20 - 07), - |
ispunct | int ispunct(int ); , - - ( iscntrl isspase), - |
isspace | int isspace(int ); , - : , , , (0x09 - 00D, 0x20), - |
2.3
- stdio.h
getch | Int getch(void); |
getchar | Int getchar (void); (stdin) |
gets | char * gets(char *s); (rand); seed - |
printf | Int printf(char * format [, argument,]); stdout |
putchar | Int putchar (int f); f (stdout) |
Puts | Int puts(const char *s); s (stdout) |
scanf | Int scanf(char* format[, argument, ]); stdin |
sprintf | i nt sprintf(char*s, char* format [, argument, ]); s |
sscanf | int sscanf(char*s, char * format [, address, ]); |
ungetch | Int ungetch(int f); f stdio, |
2.4
string.h stdlib.h
Atof | Double atof (char* str); str double |
Atoi | Int atoi(char* str); str |
itoa | Char * itoa (long v, char*str, int baz); v str. baz (2£ baz£ 36). baz = 10 |
ltoa | char * ltoa (long v, char*str, int baz); v str. baz (2£ baz£ 36) |
strcat | char * strcat(char* sp, char *si); si sp ( ) |
strchr | char* strchr(char* str, int c); str |
strcmp | strcmp(char* str1, char* str2); str1 str2. , str1 < str2; , str1 == str2 , str1> str2 ( ) |
strcpy | char* strcpy(char* sp, char* si); si sp |
strcspn | int strcspn (char * str1, char* str2); str1, , str2 |
strdup | char* strdup(const char* str); str |
strlen | Unsigned int strlen (char *str); str . |
strlwr | Char* strlwr(char*str); |
strncat | char * strncat(char*sp, shar* si, int kol); kol si sp () |
strupr | Char * strupr(char* str); str |
Ultoa | Char* ultoa (unsigned long v, char* str, int baz); str |
2.5
stdlib.h, alloc.h
calloc | void *calloc(unsigned n, unsigned m); n m . NULL |
free | void free(void *b1); b1 |
malloc | void* malloc (unsigned s); s . NULL |
realloc | void* realloc (void* bl, unsigned ns); bl ns . bl NULL, malloc() |
2.6
conio.h
clreol | void clreol(void); . |
clrscr | void clrscr (void); |
Gotoxy | void gotoxy(int x, int y); (x, y) |
highvideo | void highvideo(void); , |
normvideo | void normvideo (void); |
textattr | void textattr (int newattr); (, ) , |
textbackground | void textbackground(int ); |
textcolor | void textcolor(int c); |
textmode | void textmode (int m); m; |
whrex | int wherex(void); |
whrery | int wherey(void); |
window | void window (int x0, int y0, int x1, int y1); |
2. 7
delay | void delay (unsigned x); | dos.h |
kbhit | int kbhit (void); , , | conio.h |
nosound | void nosound(void); , sound() | dos.h |
rand | int rand(void); 0 215, srand() | stdlib.h |
sound | void sound(unsigned f); f | dos.h |
srand | void srand(unsigned seed); (rand); seed - | stdlib.h |