Основы языка программирования C++ с применением объектно-ориентированного программирования. Чернышов М.К. - 10 стр.

UptoLike

Составители: 

321ɤɨɧɫɬɚɧɬɚ ɬɢɩɚ int,
5326uɤɨɧɫɬɚɧɬɚ ɬɢɩɚ unsigned int,
45637778ɤɨɧɫɬɚɧɬɚ ɬɢɩɚ long int,
2746Lɤɨɧɫɬɚɧɬɚ ɬɢɩɚ long int.
ɐɟɥɵɟ ɤɨɧɫɬɚɧɬɵ ɦɨɝɭɬ ɡɚɩɢɫɵɜɚɬɶɫɹ ɜ ɜɨɫɶɦɟɪɢɱɧɨɣ ɫɢɫɬɟɦɟ ɫɱɢɫ-
ɥɟɧɢɹ, ɜ ɷɬɨɦ ɫɥɭɱɚɟ ɩɟɪɜɨɣ ɰɢɮɪɨɣ ɞɨɥɠɧɚ ɛɵɬɶ ɰɢɮɪɚ
0, ɱɢɫɥɨ ɦɨɠɟɬ
ɫɨɞɟɪɠɚɬɶ ɬɨɥɶɤɨ ɰɢɮɪɵ
0 ... 7:
0777ɤɨɧɫɬɚɧɬɚ ɬɢɩɚ int,
0453377ɤɨɧɫɬɚɧɬɚ ɬɢɩɚ long int.
ɐɟɥɵɟ ɤɨɧɫɬɚɧɬɵ ɦɨɠɧɨ ɡɚɩɢɫɵɜɚɬɶ ɢ ɜ ɲɟɫɬɧɚɞɰɚɬɟɪɢɱɧɨɣ ɫɢɫɬɟɦɟ
ɫɱɢɫɥɟɧɢɹ, ɜ ɷɬɨɦ ɫɥɭɱɚɟ ɡɚɩɢɫɶ ɤɨɧɫɬɚɧɬɵ ɧɚɱɢɧɚɟɬɫɹ ɫ ɫɢɦɜɨɥɨɜ
0x ɢɥɢ
0X:
0x45Fɤɨɧɫɬɚɧɬɚ ɬɢɩɚ int,
0xFFFFFFFFɤɨɧɫɬɚɧɬɚ ɬɢɩɚ unsigned long int.
Ʉɨɧɫɬɚɧɬɵ ɬɢɩɚ
char ɜɫɟɝɞɚ ɡɚɤɥɸɱɚɸɬɫɹ ɜ ɨɞɢɧɨɱɧɵɟ ɤɚɜɵɱɤɢ, ɡɧɚ-
ɱɟɧɢɟ ɤɨɧɫɬɚɧɬɵ ɡɚɞɚɟɬɫɹ ɥɢɛɨ ɡɧɚɤɨɦ ɢɡ ɢɫɩɨɥɶɡɭɟɦɨɝɨ ɧɚɛɨɪɚ ɫɢɦɜɨɥɨɜ,
ɥɢɛɨ ɰɟɥɨɣ ɤɨɧɫɬɚɧɬɨɣ, ɤɨɬɨɪɨɣ ɩɪɟɞɲɟɫɬɜɭɟɬ ɨɛɪɚɬɧɚɹ ɤɨɫɚɹ ɱɟɪɬɚ:
'A',
'\33', '\042', '\x1B'. ɂɦɟɟɬɫɹ ɬɚɤɠɟ ɪɹɞ ɫɩɟɰɢɚɥɶɧɵɯ ɫɢɦɜɨɥɨɜ, ɤɨ-
ɬɨɪɵɟ ɦɨɝɭɬ ɭɤɚɡɵɜɚɬɶɫɹ ɜ ɤɚɱɟɫɬɜɟ ɡɧɚɱɟɧɢɣ ɤɨɧɫɬɚɧɬɵ ɬɢɩɚ
char:
'\n'ɧɨɜɚɹ ɫɬɪɨɤɚ,
'\t'ɝɨɪɢɡɨɧɬɚɥɶɧɚɹ ɬɚɛɭɥɹɰɢɹ,
'\v'ɜɟɪɬɢɤɚɥɶɧɚɹ ɬɚɛɭɥɹɰɢɹ,
'\r'ɩɟɪɟɜɨɞ ɤɚɪɟɬɤɢ,
'\f'ɩɟɪɟɜɨɞ ɫɬɪɚɧɢɰɵ,
'\a'ɡɜɭɤɨɜɨɣ ɫɢɝɧɚɥ,
'\''ɨɞɢɧɨɱɧɚɹ ɤɚɜɵɱɤɚ (ɚɩɨɫɬɪɨɮ),
'\"'ɞɜɨɣɧɚɹ ɤɚɜɵɱɤɚ,
'\\'ɨɛɪɚɬɧɚɹ ɤɨɫɚɹ ɱɟɪɬɚ.
ȼɟɳɟɫɬɜɟɧɧɵɟ ɱɢɫɥɚ ɦɨɝɭɬ ɛɵɬɶ ɡɧɚɱɟɧɢɹɦɢ ɨɞɧɨɝɨ ɢɡ ɬɪɟɯ ɬɢɩɨɜ:
float, double, long double. Ⱦɢɚɩɚɡɨɧ ɡɧɚɱɟɧɢɣ ɤɚɠɞɨɝɨ ɢɡ ɷɬɢɯ ɬɢɩɨɜ
ɡɚɜɢɫɢɬ ɨɬ ɢɫɩɨɥɶɡɭɟɦɵɯ ɗȼɆ ɢ ɤɨɦɩɢɥɹɬɨɪɚ. Ʉɨɧɫɬɚɧɬɵ ɜɟɳɟɫɬɜɟɧɧɵɯ
ɬɢɩɨɜ ɦɨɝɭɬ ɡɚɩɢɫɵɜɚɬɶɫɹ ɤɚɤ ɜ ɮɨɪɦɟ ɫ ɮɢɤɫɢɪɨɜɚɧɧɨɣ ɬɨɱɤɨɣ, ɬɚɤ ɢ ɜ
ɷɤɫɩɨɧɟɧɰɢɚɥɶɧɨɣ ɮɨɪɦɟ. ɉɨ ɭɦɨɥɱɚɧɢɸ ɨɧɢ ɢɦɟɸɬ ɬɢɩ
double, ɧɚɩɪɢ-
ɦɟɪ,
15.31, 1.43E-3, 2345.1e4. ɉɪɢ ɧɟɨɛɯɨɞɢɦɨɫɬɢ ɬɢɩ ɤɨɧɫɬɚɧɬɵ
ɦɨɠɧɨ ɭɬɨɱɧɢɬɶ, ɡɚɩɢɫɚɜ ɜ ɤɨɧɰɟ ɫɭɮɮɢɤɫ
f ɢɥɢ F ɞɥɹ ɬɢɩɚ float, ɫɭɮ-
ɮɢɤɫ
l ɢɥɢ L ɞɥɹ ɬɢɩɚ long double.
ȼɧɟɲɧɟɟ ɨɩɪɟɞɟɥɟɧɢɟ, ɨɛɴɹɜɥɹɸɳɟɟ ɩɟɪɟɦɟɧɧɵɟ, ɫɨɫɬɨɢɬ ɢɡ ɧɟɨɛɹɡɚ-
ɬɟɥɶɧɨɝɨ ɫɩɟɰɢɮɢɤɚɬɨɪɚ ɤɥɚɫɫɚ ɩɚɦɹɬɢ, ɫɩɟɰɢɮɢɤɚɬɨɪɨɜ ɬɢɩɚ ɢ ɫɩɢɫɤɚ
ɞɟɤɥɚɪɚɬɨɪɨɜ-ɢɧɢɰɢɚɥɢɡɚɬɨɪɨɜ, ɤɚɠɞɵɣ ɢɡ ɤɨɬɨɪɵɯ ɨɛɴɹɜɥɹɟɬ ɢɞɟɧɬɢɮɢ-
ɤɚɬɨɪ ɨɞɧɨɣ ɩɟɪɟɦɟɧɧɨɣ ɢ, ɜɨɡɦɨɠɧɨ, ɡɧɚɱɟɧɢɟ, ɩɪɢɫɜɚɢɜɚɟɦɨɟ ɩɟɪɟɦɟɧ-
ɧɨɣ ɩɪɢ ɟɟ ɨɛɴɹɜɥɟɧɢɢ. ȼɧɟɲɧɟɟ ɨɩɪɟɞɟɥɟɧɢɟ ɡɚɤɚɧɱɢɜɚɟɬɫɹ ɬɨɱɤɨɣ ɫ ɡɚ-
ɩɹɬɨɣ:
10
       321 – ɤɨɧɫɬɚɧɬɚ ɬɢɩɚ int,
       5326u – ɤɨɧɫɬɚɧɬɚ ɬɢɩɚ unsigned int,
       45637778 – ɤɨɧɫɬɚɧɬɚ ɬɢɩɚ long int,
       2746L – ɤɨɧɫɬɚɧɬɚ ɬɢɩɚ long int.
    ɐɟɥɵɟ ɤɨɧɫɬɚɧɬɵ ɦɨɝɭɬ ɡɚɩɢɫɵɜɚɬɶɫɹ ɜ ɜɨɫɶɦɟɪɢɱɧɨɣ ɫɢɫɬɟɦɟ ɫɱɢɫ-
ɥɟɧɢɹ, ɜ ɷɬɨɦ ɫɥɭɱɚɟ ɩɟɪɜɨɣ ɰɢɮɪɨɣ ɞɨɥɠɧɚ ɛɵɬɶ ɰɢɮɪɚ 0, ɱɢɫɥɨ ɦɨɠɟɬ
ɫɨɞɟɪɠɚɬɶ ɬɨɥɶɤɨ ɰɢɮɪɵ 0 ... 7:
     0777 – ɤɨɧɫɬɚɧɬɚ ɬɢɩɚ int,
     0453377 – ɤɨɧɫɬɚɧɬɚ ɬɢɩɚ long int.
    ɐɟɥɵɟ ɤɨɧɫɬɚɧɬɵ ɦɨɠɧɨ ɡɚɩɢɫɵɜɚɬɶ ɢ ɜ ɲɟɫɬɧɚɞɰɚɬɟɪɢɱɧɨɣ ɫɢɫɬɟɦɟ
ɫɱɢɫɥɟɧɢɹ, ɜ ɷɬɨɦ ɫɥɭɱɚɟ ɡɚɩɢɫɶ ɤɨɧɫɬɚɧɬɵ ɧɚɱɢɧɚɟɬɫɹ ɫ ɫɢɦɜɨɥɨɜ 0x ɢɥɢ
0X:
       0x45F – ɤɨɧɫɬɚɧɬɚ ɬɢɩɚ int,
       0xFFFFFFFF – ɤɨɧɫɬɚɧɬɚ ɬɢɩɚ unsigned long int.
      Ʉɨɧɫɬɚɧɬɵ ɬɢɩɚ char ɜɫɟɝɞɚ ɡɚɤɥɸɱɚɸɬɫɹ ɜ ɨɞɢɧɨɱɧɵɟ ɤɚɜɵɱɤɢ, ɡɧɚ-
ɱɟɧɢɟ ɤɨɧɫɬɚɧɬɵ ɡɚɞɚɟɬɫɹ ɥɢɛɨ ɡɧɚɤɨɦ ɢɡ ɢɫɩɨɥɶɡɭɟɦɨɝɨ ɧɚɛɨɪɚ ɫɢɦɜɨɥɨɜ,
ɥɢɛɨ ɰɟɥɨɣ ɤɨɧɫɬɚɧɬɨɣ, ɤɨɬɨɪɨɣ ɩɪɟɞɲɟɫɬɜɭɟɬ ɨɛɪɚɬɧɚɹ ɤɨɫɚɹ ɱɟɪɬɚ: 'A',
'\33', '\042', '\x1B'. ɂɦɟɟɬɫɹ ɬɚɤɠɟ ɪɹɞ ɫɩɟɰɢɚɥɶɧɵɯ ɫɢɦɜɨɥɨɜ, ɤɨ-
ɬɨɪɵɟ ɦɨɝɭɬ ɭɤɚɡɵɜɚɬɶɫɹ ɜ ɤɚɱɟɫɬɜɟ ɡɧɚɱɟɧɢɣ ɤɨɧɫɬɚɧɬɵ ɬɢɩɚ char:
     '\n' – ɧɨɜɚɹ ɫɬɪɨɤɚ,
     '\t' – ɝɨɪɢɡɨɧɬɚɥɶɧɚɹ ɬɚɛɭɥɹɰɢɹ,
     '\v' – ɜɟɪɬɢɤɚɥɶɧɚɹ ɬɚɛɭɥɹɰɢɹ,
     '\r' – ɩɟɪɟɜɨɞ ɤɚɪɟɬɤɢ,
     '\f' – ɩɟɪɟɜɨɞ ɫɬɪɚɧɢɰɵ,
     '\a' – ɡɜɭɤɨɜɨɣ ɫɢɝɧɚɥ,
     '\'' – ɨɞɢɧɨɱɧɚɹ ɤɚɜɵɱɤɚ (ɚɩɨɫɬɪɨɮ),
     '\"' – ɞɜɨɣɧɚɹ ɤɚɜɵɱɤɚ,
     '\\' – ɨɛɪɚɬɧɚɹ ɤɨɫɚɹ ɱɟɪɬɚ.
    ȼɟɳɟɫɬɜɟɧɧɵɟ ɱɢɫɥɚ ɦɨɝɭɬ ɛɵɬɶ ɡɧɚɱɟɧɢɹɦɢ ɨɞɧɨɝɨ ɢɡ ɬɪɟɯ ɬɢɩɨɜ:
float, double, long double. Ⱦɢɚɩɚɡɨɧ ɡɧɚɱɟɧɢɣ ɤɚɠɞɨɝɨ ɢɡ ɷɬɢɯ ɬɢɩɨɜ
ɡɚɜɢɫɢɬ ɨɬ ɢɫɩɨɥɶɡɭɟɦɵɯ ɗȼɆ ɢ ɤɨɦɩɢɥɹɬɨɪɚ. Ʉɨɧɫɬɚɧɬɵ ɜɟɳɟɫɬɜɟɧɧɵɯ
ɬɢɩɨɜ ɦɨɝɭɬ ɡɚɩɢɫɵɜɚɬɶɫɹ ɤɚɤ ɜ ɮɨɪɦɟ ɫ ɮɢɤɫɢɪɨɜɚɧɧɨɣ ɬɨɱɤɨɣ, ɬɚɤ ɢ ɜ
ɷɤɫɩɨɧɟɧɰɢɚɥɶɧɨɣ ɮɨɪɦɟ. ɉɨ ɭɦɨɥɱɚɧɢɸ ɨɧɢ ɢɦɟɸɬ ɬɢɩ double, ɧɚɩɪɢ-
ɦɟɪ, 15.31, 1.43E-3, 2345.1e4. ɉɪɢ ɧɟɨɛɯɨɞɢɦɨɫɬɢ ɬɢɩ ɤɨɧɫɬɚɧɬɵ
ɦɨɠɧɨ ɭɬɨɱɧɢɬɶ, ɡɚɩɢɫɚɜ ɜ ɤɨɧɰɟ ɫɭɮɮɢɤɫ f ɢɥɢ F ɞɥɹ ɬɢɩɚ float, ɫɭɮ-
ɮɢɤɫ l ɢɥɢ L ɞɥɹ ɬɢɩɚ long double.
    ȼɧɟɲɧɟɟ ɨɩɪɟɞɟɥɟɧɢɟ, ɨɛɴɹɜɥɹɸɳɟɟ ɩɟɪɟɦɟɧɧɵɟ, ɫɨɫɬɨɢɬ ɢɡ ɧɟɨɛɹɡɚ-
ɬɟɥɶɧɨɝɨ ɫɩɟɰɢɮɢɤɚɬɨɪɚ ɤɥɚɫɫɚ ɩɚɦɹɬɢ, ɫɩɟɰɢɮɢɤɚɬɨɪɨɜ ɬɢɩɚ ɢ ɫɩɢɫɤɚ
ɞɟɤɥɚɪɚɬɨɪɨɜ-ɢɧɢɰɢɚɥɢɡɚɬɨɪɨɜ, ɤɚɠɞɵɣ ɢɡ ɤɨɬɨɪɵɯ ɨɛɴɹɜɥɹɟɬ ɢɞɟɧɬɢɮɢ-
ɤɚɬɨɪ ɨɞɧɨɣ ɩɟɪɟɦɟɧɧɨɣ ɢ, ɜɨɡɦɨɠɧɨ, ɡɧɚɱɟɧɢɟ, ɩɪɢɫɜɚɢɜɚɟɦɨɟ ɩɟɪɟɦɟɧ-
ɧɨɣ ɩɪɢ ɟɟ ɨɛɴɹɜɥɟɧɢɢ. ȼɧɟɲɧɟɟ ɨɩɪɟɞɟɥɟɧɢɟ ɡɚɤɚɧɱɢɜɚɟɬɫɹ ɬɨɱɤɨɣ ɫ ɡɚ-
ɩɹɬɨɣ:
                                   10