Stroustrup 4.11练习4 [英] Stroustrup 4.11 exercise 4

查看:56
本文介绍了Stroustrup 4.11练习4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解决方案运行良好,但我无法做十六进制。部分。

对此有何帮助?


--------- PROGRAM ------------- -

/ * TC ++ PL 3e,4.11练习4

声明:

写一个打印出来的程序字母''''''''z'',

位数''0''到''9''及其整数值。为

其他可打印字符做同样的事情。再做一次但是使用十六进制

表示法。

* /


#include< iostream>


int main()

{

for(int i = 0; i< = 127; ++ i)

{

std :: cout<< "''"

<< char(i)

<< "'':\ t"

<<我

<< std :: endl;

}


返回0;

}


--------- OUTPUT -------------


注意:这里有些字符没有正确显示但在我的GNOME-

终端显示没有任何问题。


[arch @ voodo tc ++ pl] $ ./a.out

'''':0

''?'':1

''?'':2

'''''': 3

''?'':4

'''':5

''?'':6

'''':7

'':8

'''':9

''

'':10

''

'':11

''

'': 12

'':13

'''':14

'''':15

' '?'':16

''?'':17

''?'':18

'''''': 19

'''''' :20

''?'':21

''?'':22

''?'':23
''?'':24

''?'':25

''?'':26

''?'':27

''?'':28

''?'':29

'''''' :30

''?'':31

'''':32

''!''':33

''"'':34

''#'':35

''$'':36

''%'':37

''&'':38

'''''':39

''( '':40

''''':41

''*'':42

''+'':43

'','':44

'' - '':45

''。''':46

''/'':47

''0'':48

''1'':49

''2 '':50

''3 '':51

''4'':52

''5'':53

''6'':54

''7'':55

''8'':56

''9'':57

'':'':58

'';'':59

''<'':60

'' ='':61

''>'':62

''?'':63

''@'': 64

''A'':65

''B'':66

''C'':67

''D'':68

''E'':69

''F'':70

' 'G'':71

''H'':72

''我':73

''J'': 74

''K'':75

''L'':76

''M'':77

''N'':78

''O'':79

''P'':80

' 'Q'':81

''R ':82

''''':83

''T'':84

''U'':85

''V'':86

''W'':87

''X'':88

''Y'':89

''Z'':90

''['':91

''\ '':92

''''':93

''^'':94

''_'':95

''''':96

''''':97

''b'':98

''c'':99

''d'':100

''e'':101

''f '':102

''g'':103

''h'':104

''我':105

''j'':106

''k'':107

''l'':108

''m'':109

''n'':110

''o'':111

''p '':112

''q'':113

''r'':114

'''':115

''t'' :116

''u'':117

''v'':118

''w'':119
''x'':120

''y'':121

''z'':122

''{'':123

''|'':124

''''':125

'''''' :126

''?'':127

[arch @ voodo tc ++ pl] $

solution runs fine but i was not able to do the "hexadecimal" part .
any help on that ?

--------- PROGRAMME ---------------
/* TC++PL 3e, 4.11 exercise 4

STATEMENT:
write a programme that prints out the letters ''a''...''z'',
digits ''0'' to ''9'' and their integer values. do the same for
other printable characters. Do the same again but use hexadecimal
notation.
*/

#include<iostream>

int main()
{
for(int i=0; i <= 127; ++i)
{
std::cout << "''"
<< char(i)
<< "'' : \t"
<< i
<< std::endl;
}

return 0;
}

--------- OUTPUT -------------

NOTE: here some characters are not displayed properly but on my GNOME-
Terminal they were displayed without any trouble.

[arch@voodo tc++pl]$ ./a.out
'''' : 0
'''' : 1
'''' : 2
'''' : 3
'''' : 4
'''' : 5
'''' : 6
'''' : 7
'' : 8
'' '' : 9
''
'' : 10
''
'' : 11
''
'' : 12
'' : 13
'''' : 14
'''' : 15
'''' : 16
'''' : 17
'''' : 18
'''' : 19
'''' : 20
'''' : 21
'''' : 22
'''' : 23
'''' : 24
'''' : 25
'''' : 26
'''' : 27
'''' : 28
'''' : 29
'''' : 30
'''' : 31
'' '' : 32
''!'' : 33
''"'' : 34
''#'' : 35
''$'' : 36
''%'' : 37
''&'' : 38
'''''' : 39
''('' : 40
'')'' : 41
''*'' : 42
''+'' : 43
'','' : 44
''-'' : 45
''.'' : 46
''/'' : 47
''0'' : 48
''1'' : 49
''2'' : 50
''3'' : 51
''4'' : 52
''5'' : 53
''6'' : 54
''7'' : 55
''8'' : 56
''9'' : 57
'':'' : 58
'';'' : 59
''<'' : 60
''='' : 61
''>'' : 62
''?'' : 63
''@'' : 64
''A'' : 65
''B'' : 66
''C'' : 67
''D'' : 68
''E'' : 69
''F'' : 70
''G'' : 71
''H'' : 72
''I'' : 73
''J'' : 74
''K'' : 75
''L'' : 76
''M'' : 77
''N'' : 78
''O'' : 79
''P'' : 80
''Q'' : 81
''R'' : 82
''S'' : 83
''T'' : 84
''U'' : 85
''V'' : 86
''W'' : 87
''X'' : 88
''Y'' : 89
''Z'' : 90
''['' : 91
''\'' : 92
'']'' : 93
''^'' : 94
''_'' : 95
''`'' : 96
''a'' : 97
''b'' : 98
''c'' : 99
''d'' : 100
''e'' : 101
''f'' : 102
''g'' : 103
''h'' : 104
''i'' : 105
''j'' : 106
''k'' : 107
''l'' : 108
''m'' : 109
''n'' : 110
''o'' : 111
''p'' : 112
''q'' : 113
''r'' : 114
''s'' : 115
''t'' : 116
''u'' : 117
''v'' : 118
''w'' : 119
''x'' : 120
''y'' : 121
''z'' : 122
''{'' : 123
''|'' : 124
''}'' : 125
''~'' : 126
'''' : 127
[arch@voodo tc++pl]$

推荐答案

./ a.out

'''':0

''?'':1

''?'':2

''?'':3

''?'':4

''' ':5

''?'':6

'''':7

'':8

'''':9

''

'':10

''

'' :11

''

'':12

'':13

'''':14

' ''':15

''?'':16

''?'':17

'''''':18

''?'':19

''?'':20

''?'':21

''?'':22

''?'':23

''?'':24

'' ?'':25

''?'':26

''?'':27

''?''':28

''?'':29

''?'':30

''?'':31

'''':32

''!'':33

''"'':34

'' #'':35

''
./a.out
'''' : 0
'''' : 1
'''' : 2
'''' : 3
'''' : 4
'''' : 5
'''' : 6
'''' : 7
'' : 8
'' '' : 9
''
'' : 10
''
'' : 11
''
'' : 12
'' : 13
'''' : 14
'''' : 15
'''' : 16
'''' : 17
'''' : 18
'''' : 19
'''' : 20
'''' : 21
'''' : 22
'''' : 23
'''' : 24
'''' : 25
'''' : 26
'''' : 27
'''' : 28
'''' : 29
'''' : 30
'''' : 31
'' '' : 32
''!'' : 33
''"'' : 34
''#'' : 35
''


'':36

''%'':37

''&'':38

'''''':39

''('':40

'')'':41

''*'':42

''+'':43

'','':44

'' - '':45

''。'':46

''/'':47

'' 0'':48

''1'':49

''2'':50

''3'':51

''4'':52

''5'':53

''6'':54

''7'':55

''8'':56

''9'':57

'' :'':58

'';'':59

''<'':60

''='': 61

''>'':62

''?'':63

''@'':64
''A'':65

''B'':66

''C'':67

''D'':68

''E'':69

''F'':70

''G'' :71

''H'':72
''我':73

''J'':74

''K'':75

''L'':76

''M'':77

''N'':78

''O '':79

''P'':80

''Q'':81

''R'':82

''''':83

''T'':84

''U'':85

''V'':86

''W'':87

''X'':88

''Y '':89

''Z'':90

''['':91

''\'':92

''''':93

''^'':94

''_'':95

''''':96

''''':97

''b'':98

'' c'':99

''d'':100

''e'':101

''f'':102

''g'':103

''h'':104

''我':105

''j'':106

''k'':107

''l'':108

''m'':109

''n '':110

''o'':111

''p'':112

''q'':113

''r'':114

''''':115

''t'':116

''u'':117

''v'':118

''w'':119

''x '':120

''y'':121

''z'':122

''{'':123

''|'':124

''''':125

''〜'':126

''?'':127

[arch @ voodo tc ++ pl]
'' : 36
''%'' : 37
''&'' : 38
'''''' : 39
''('' : 40
'')'' : 41
''*'' : 42
''+'' : 43
'','' : 44
''-'' : 45
''.'' : 46
''/'' : 47
''0'' : 48
''1'' : 49
''2'' : 50
''3'' : 51
''4'' : 52
''5'' : 53
''6'' : 54
''7'' : 55
''8'' : 56
''9'' : 57
'':'' : 58
'';'' : 59
''<'' : 60
''='' : 61
''>'' : 62
''?'' : 63
''@'' : 64
''A'' : 65
''B'' : 66
''C'' : 67
''D'' : 68
''E'' : 69
''F'' : 70
''G'' : 71
''H'' : 72
''I'' : 73
''J'' : 74
''K'' : 75
''L'' : 76
''M'' : 77
''N'' : 78
''O'' : 79
''P'' : 80
''Q'' : 81
''R'' : 82
''S'' : 83
''T'' : 84
''U'' : 85
''V'' : 86
''W'' : 87
''X'' : 88
''Y'' : 89
''Z'' : 90
''['' : 91
''\'' : 92
'']'' : 93
''^'' : 94
''_'' : 95
''`'' : 96
''a'' : 97
''b'' : 98
''c'' : 99
''d'' : 100
''e'' : 101
''f'' : 102
''g'' : 103
''h'' : 104
''i'' : 105
''j'' : 106
''k'' : 107
''l'' : 108
''m'' : 109
''n'' : 110
''o'' : 111
''p'' : 112
''q'' : 113
''r'' : 114
''s'' : 115
''t'' : 116
''u'' : 117
''v'' : 118
''w'' : 119
''x'' : 120
''y'' : 121
''z'' : 122
''{'' : 123
''|'' : 124
''}'' : 125
''~'' : 126
'''' : 127
[arch@voodo tc++pl]







这篇关于Stroustrup 4.11练习4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆