comparison test/short.c @ 170:6e0f67b7d200 short-fix

test files
author kono
date Mon, 24 Nov 2003 20:15:14 +0900
parents
children 096559f07a70
comparison
equal deleted inserted replaced
169:b2a480be3c85 170:6e0f67b7d200
1
2 short gj;
3 short gi;
4
5 short a[100];
6 unsigned short b[100];
7 unsigned char c[100];
8
9 short data[] = {10,20,-40};
10 unsigned short udata[] = {10,20,-40};
11
12 short f(short i,unsigned short j,unsigned short k,short m,short a);
13 unsigned
14 short g(short i,unsigned short j,unsigned short k,short m,short a);
15
16 main()
17 {
18 int ii;
19 short i,k,*p;
20 unsigned short j,m,*up;
21 unsigned char g0,h0;
22 char g1,h1;
23 unsigned short sg0,sh0;
24 short sg1,sh1;
25 unsigned char *pg0,*ph0;
26 char *pg1,*ph1;
27 unsigned short *psg0,*psh0;
28 short *psg1,*psh1;
29
30
31 i = -3;
32 j = 3;
33 k = 44;
34 k = i*j+3+k;
35 m = i*j-7+k;
36 printf("%d %d %d\n",i,k,m);
37
38 g0 = 123;
39 g0++; --g0;
40 ++g0; g0--;
41 printf("g0=%d\n",g0);
42 g1 = -123;
43 g1++; --g1;
44 ++g1; g1--;
45 printf("g1=%d\n",g1);
46
47 sg0 = 123;
48 sg0++; --sg0;
49 ++sg0; sg0--;
50 printf("sg0=%d\n",sg0);
51 sg1 = -123;
52 sg1++; --sg1;
53 ++sg1; sg1--;
54 printf("sg1=%d\n",sg1);
55
56 pg0 = &g0;
57 ph0 = &h0;
58 *pg0 = 123;
59 //*pg0++; *--pg0;
60 //*++pg0; *g0--;
61 printf("g0=%d\n",*pg0);
62 pg1 = &g1;
63 ph1 = &h1;
64 *pg1 = -123;
65 //*pg1++; --*pg1;
66 //++*pg1; *pg1--;
67 printf("g1=%d\n",*pg1);
68
69 psg0 = &sg0;
70 psh0 = &sh0;
71 *psg0 = 123;
72 //*sg0++; *--sg0;
73 //*++sg0; *sg0--;
74 printf("sg0=%d\n",*psg0);
75 psg1 = &sg1;
76 psh1 = &sh1;
77 *psg1 = -123;
78 //*sg1++; *--sg1;
79 //*++sg1; *sg1--;
80 printf("sg1=%d\n",*psg1);
81
82
83 h0 = g0 - 20;
84 c[33] = g0;
85
86 if (i==j) { printf("i==j\n"); } else { printf("i!=j\n"); }
87
88 a[33] = i;
89 b[33] = 105;
90 printf("i=%d\n",i);
91 printf("j=%d\n",j);
92 i++; --i;
93 j++; --j;
94 printf("i=%d\n",i);
95 printf("j=%d\n",j);
96 gi = 3333;
97 gj = 6666;
98 gi++; --gi;
99 gj++; --gj;
100 printf("gi=%d\n",gi);
101 printf("gj=%d\n",gj);
102
103 printf("k=%d\n",k);
104 printf("m=%d\n",m);
105 printf("a[33]=%d\n",a[33]);
106 printf("b[33]=%d\n",b[33]);
107 printf("a[33]=%d\n",++a[33]);
108 printf("b[33]=%d\n",b[33]--);
109
110 printf("g0=%d\n",g0);
111 printf("h0=%d\n",h0);
112 printf("c[33]=%d\n",c[33]);
113
114 p = data;
115 printf("*p++ = %d\n",*p++);
116 printf("*++p = %d\n",*++p);
117 *p++ = -343;
118 printf("*p-- = %d\n",*p--);
119 printf("*--p = %d\n",*--p);
120 up = udata;
121 printf("*up-- = %d\n",*up--);
122 printf("*--up = %d\n",*--up);
123 *up++ = 65530;
124 printf("*up-- = %d\n",*up--);
125 printf("*--up = %d\n",*--up);
126
127
128 ii = f(i,j,k,m,a[33]);
129 printf("f()=%d\n",ii);
130 ii = g(i,j,k,m,a[33]);
131 printf("f()=%d\n",ii);
132
133 }
134
135 short f(short i,unsigned short j,unsigned short k,short m,short a)
136 {
137 return i+j*k-m/a;
138 }
139
140 unsigned
141 short g(short i,unsigned short j,unsigned short k,short m,short a)
142 {
143 return i+j*k-m/a;
144 }