如何对double型变量进行memset获得极大值或极小值

我们都知道,如果想对int型变量清极大值或极小值,我们一般选择memset(a,0x3f,sizeof a);或者memset(a,0xef,sizeof a);。然而,如果对double型清0x3f,我们经常会得到一个连1都不到的小数。那么对double清极值是否智能手动或者fill(a+1,a+n,0x7fffffff);呢?

首先我们运行以下程序

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    double x;
    freopen("1.txt","w",stdout);
    for(int i=1;i<=0xff;i++)
        memset(&x,i,sizeof x),printf("%x %.2lf\n",i,x);
}

得到这个表:

1 0.00

2 0.00

3 0.00

4 0.00

5 0.00

6 0.00

7 0.00

8 0.00

9 0.00

a 0.00

b 0.00

c 0.00

d 0.00

e 0.00

f 0.00

10 0.00

11 0.00

12 0.00

13 0.00

14 0.00

15 0.00

16 0.00

17 0.00

18 0.00

19 0.00

1a 0.00

1b 0.00

1c 0.00

1d 0.00

1e 0.00

1f 0.00

20 0.00

21 0.00

22 0.00

23 0.00

24 0.00

25 0.00

26 0.00

27 0.00

28 0.00

29 0.00

2a 0.00

2b 0.00

2c 0.00

2d 0.00

2e 0.00

2f 0.00

30 0.00

31 0.00

32 0.00

33 0.00

34 0.00

35 0.00

36 0.00

37 0.00

38 0.00

39 0.00

3a 0.00

3b 0.00

3c 0.00

3d 0.00

3e 0.00

3f 0.00

40 32.50

41 2261634.51

42 156842099844.52

43 10843961455707782.00

44 747708026454360460000.00

45 51429126632076458000000000.00

46 3529536965341344500000000000000.00

47 241737052174609690000000000000000000.00

48 16525713066466281000000000000000000000000.00

49 1127805529726474100000000000000000000000000000.00

4a 76846329228755865000000000000000000000000000000000.00

4b 5228514198248326500000000000000000000000000000000000000.00

4c 355259342137649310000000000000000000000000000000000000000000.00

4d 24108255004517747000000000000000000000000000000000000000000000000.00

4e 1634089943872471700000000000000000000000000000000000000000000000000000.00

4f 110639270315220550000000000000000000000000000000000000000000000000000000000.00

50 7556001431015456300000000000000000000000000000000000000000000000000000000000000.00

51 525663347308138420000000000000000000000000000000000000000000000000000000000000000000.00

52 36446967223631734000000000000000000000000000000000000000000000000000000000000000000000000.00

53 2519470002541514500000000000000000000000000000000000000000000000000000000000000000000000000000.00

54 173693439909239170000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

55 11945305291614955000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

56 819687411242631950000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

57 56133372798172279000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

58 3836982815172030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

59 261830011167902370000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

5a 17838867517321418000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

5b 1213624708152897500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

5c 82454865162444373000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

5d 5595045655437669700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

5e 379212874880737930000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

5f 25673651826636406000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

60 1756580577739302900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

61 122176384420437770000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

62 8469446924576528300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

63 585363771868790560000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

64 40348802750122149000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

65 2774480017624350000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

66 190359856625529320000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

67 13034546188519292000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

68 890874679343703260000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

69 60785776373046065000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

6a 4141035668152201600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

6b 281700905511843030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

6c 19137488320965074000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

6d 1298492692778582300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

6e 88001147761747392000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

6f 5957502789848767900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

70 408354876418796630000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

71 28396262443943004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

72 1968084071671644300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

73 135999696916777530000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

74 9372895550667632100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

75 644409915093636340000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

76 44207816532211711000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

77 3026687417964748600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

78 206842847014058100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

79 14111782168453345000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

7a 961276249046606020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

7b 65386757613253666000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

7c 4441723041807660500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

7d 301351536995410160000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

7e 20421693454608858000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

7f 1382417208487871500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

80 -0.00

81 -0.00

82 -0.00

83 -0.00

84 -0.00

85 -0.00

86 -0.00

87 -0.00

88 -0.00

89 -0.00

8a -0.00

8b -0.00

8c -0.00

8d -0.00

8e -0.00

8f -0.00

90 -0.00

91 -0.00

92 -0.00

93 -0.00

94 -0.00

95 -0.00

96 -0.00

97 -0.00

98 -0.00

99 -0.00

9a -0.00

9b -0.00

9c -0.00

9d -0.00

9e -0.00

9f -0.00

a0 -0.00

a1 -0.00

a2 -0.00

a3 -0.00

a4 -0.00

a5 -0.00

a6 -0.00

a7 -0.00

a8 -0.00

a9 -0.00

aa -0.00

ab -0.00

ac -0.00

ad -0.00

ae -0.00

af -0.00

b0 -0.00

b1 -0.00

b2 -0.00

b3 -0.00

b4 -0.00

b5 -0.00

b6 -0.00

b7 -0.00

b8 -0.00

b9 -0.00

ba -0.00

bb -0.00

bc -0.00

bd -0.00

be -0.00

bf -0.12

c0 -8577.51

c1 -595821443.51

c2 -41255400998277.52

c3 -2848394305499268600.00

c4 -196154140339432450000000.00

c5 -13476555094338099000000000000.00

c6 -923923411592226570000000000000000.00

c7 -63219126011291991000000000000000000000.00

c8 -4318036447754703500000000000000000000000000.00

c9 -294449594579902470000000000000000000000000000000.00

ca -20048271934734512000000000000000000000000000000000000.00

cb -1363115719988382000000000000000000000000000000000000000000.00

cc -92559631349317831000000000000000000000000000000000000000000000.00

cd -6277438562204192500000000000000000000000000000000000000000000000000.00

ce -425255837650091480000000000000000000000000000000000000000000000000000000.00

cf -28777739825156522000000000000000000000000000000000000000000000000000000000000.00

d0 -1993854408381186000000000000000000000000000000000000000000000000000000000000000000.00

d1 -138470391314097430000000000000000000000000000000000000000000000000000000000000000000000.00

d2 -9586051653338756600000000000000000000000000000000000000000000000000000000000000000000000000.00

d3 -661737160148046550000000000000000000000000000000000000000000000000000000000000000000000000000000.00

d4 -45563434706068069000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

d5 -3129951052409979500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

d6 -214555482385487100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

d7 -14679178779048922000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

d8 -1002520540904329100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

d9 -68355779549259894000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

da -4653735800328269100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

db -316388621163970020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

dc -21482046286569577000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

dd -1456815990147462900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

de -98683099208633679000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

df -6677614145500822200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

e0 -463468064771798250000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

e1 -32180465730379564000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

e2 -2227377823277027000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

e3 -153732818170537500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

e4 -10583553036438193000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

e5 -726930037227653690000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

e6 -49824159672519490000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

e7 -3408411520223639500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

e8 -232754178434599600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

e9 -15868539665109664000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

ea -1080249646601300100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

eb -73435622782400814000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

ec -4985717045666697800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

ed -338084306397821390000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

ee -22899894549927040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

ef -1549473939178550500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

f0 -107730874267432140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

f1 -7478635795308384200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

f2 -517539169214551540000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

f3 -35714397827745240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

f4 -2458343745902715200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

f5 -168827860796461440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

f6 -11570099379335498000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

f7 -791405925073819980000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

f8 -54037958965559871000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

f9 -3683800791481180300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

fa -250751870841351620000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

fb -17044745290527055000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

fc -1157117770045540900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

fd -78459116763945423000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

fe -5314010372517807600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00

ff -1.#R

看了这么大的表,不难发现,对于double型变量,当我们想要清极大值的时候,我们可以选择0x7f,当然如果觉得这个数字过于夸张,我们可以选择0x42或者0x43。同样,想清最小值的时候,可以选择0xfe或0xc2。

时间: 2024-11-07 01:27:36

如何对double型变量进行memset获得极大值或极小值的相关文章

C++中string类型对象和double型变量之间的互相转换

//convert string type value to double type value string s = "23"; double d; istringstream is(s); is>>d; cout<<d<<endl;   //输出23 //convert double type value to string type value double d=45; string s; ostringstream os; os<<

(1)编写一个接口ShapePara,要求: 接口中的方法: int getArea():获得图形的面积。int getCircumference():获得图形的周长 (2)编写一个圆类Circle,要求:圆类Circle实现接口ShapePara。 该类包含有成员变量: radius:public 修饰的double类型radius,表示圆的半径。 x:private修饰的double型变量x,

package com.hanqi.test; //创建接口 public interface ShapePara { //获取面积的方法 double getArea(); //获取周长的方法 double getCircumference(); } package com.hanqi.test; public class Circle implements ShapePara { //定义圆心 public double radius; //定义圆心的横向坐标 private double

C++中string类型对象和double型变量之间的互相转换资邹装足字锥

http://www.ebay.com/cln/hrp_fzxt/2015-01-30/166863065016 http://www.ebay.com/cln/9f1_bvdd/2015-01-30/166863074016 http://www.ebay.com/cln/nld_pxbn/2015-01-30/166753713010 http://www.ebay.com/cln/9xt_jxfl/2015-01-30/166728590014 http://www.ebay.com/cl

double型转换成string型

double型转换成string型 题目描述: 如有一个函数,其可接受一个long double参数,并将参数转换为字符串,结果字符串应保留两位小数,例如,浮点值123.45678应该生成"123.45"这样的字符串.表面上看来 这是一个意义不大的编程问题,然而,如果真要在实际中派上用场,函数应设计为具有一定弹性,以允许调用者指定小数位数.另外,函数也应该能够处理各种异常 情况,如像123.0或123这样的整数. 转换函数接口:string do_fraction(long doubl

java 中double型转化成int型(转)

java 中double型转化成int型 一个变量 double x: //不进行四舍五入操作: (int)x //进行四舍五入操作: Integer.parseInt(new java.text.DecimalFormat("0").format(x))

java定义一个Circle类,包含一个double型的radius属性代表圆的半径,一个findArea()方法返回圆的面积

需求如下:(1)定义一个Circle类,包含一个double型的radius属性代表圆的半径,一个findArea()方法返回圆的面积. (2)定义一个类PassObject,在类中定义一个方法printAreas(),该方法的定义如下: public void printAreas(Cirlce c, int times) 在printAreas方法中打印输出1到time之间的每个整数半径值,以及对应的面积.例如,times为5,则输出半径1,2,3,4,5,以及对应的圆面积. 在main方法

字符型变量

我们都知道,除了数字以外还有其他符号,比如字母等等,这些符号就是字符,存储字符的变量就是字符型变量. 一个字符型变量只能存储一个字符,比如time这个单词,就需要四个字符变量来存储. 那么,思考下面几个问题: 字符型变量在计算机内是以什么形式存储的? 答案很显然,也是0110这类的二进制码. 那么,二进制码是怎么变成字符的? 这个问题就比较专业了,就是用到ASCII码.简单地说,就是哪个数字代表哪个字符都统一标准.比如65就代表A,97代表a. 所以实际上,字符型就是个整数. 字符型的定义: c

C语言中以十六进制输出字符型变量会出现&#39;ffffff&quot;的问题

最近在做一个C的嵌入式项目,发现在C语言中用printf()函数打印字符型变量时,如果想采用"%x"的格式将字符型变量值以十六进制形式打印出来,会出现一个小问题,如下: C代码   char buf[10] = {0}; buf[0] = 0xbf; printf("%2x\n\n\n", buf[0]);            /*在终端将会显示成:ffffffbf*/ buf[1] = 0x7f; printf("%2x\n\n\n", bu

java 复习-字符型变量

在java中,字符型变量用char 表示,用来存储字母.数字.标点符号等字符.占两个字节,用unicode编码,可以表示中文和英文.字符要用单引号包围.比如 'A'  '我' 注意事项:     有些特殊的字符,不能直接用单引号,要用转义字符表示.  (1) \n :表示换行  (2) \t :表示制表符,相当与Tab键  (3) \' :表示单引号  (4) \" :表示双引号  (5) \\ :表示一个斜杠"\"  package charTest; public cla