0% found this document useful (0 votes)
5 views

sdfsdfsdfsdgsdg

The document contains multiple C++ code snippets demonstrating various programming concepts such as structures, bitwise operations, loops, conditionals, and array manipulations. Each snippet includes a main function that performs specific operations and outputs results to the console. The overall focus is on illustrating different aspects of C++ programming through practical examples.

Uploaded by

Xbit Smarty
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

sdfsdfsdfsdgsdg

The document contains multiple C++ code snippets demonstrating various programming concepts such as structures, bitwise operations, loops, conditionals, and array manipulations. Each snippet includes a main function that performs specific operations and outputs results to the console. The overall focus is on illustrating different aspects of C++ programming through practical examples.

Uploaded by

Xbit Smarty
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1 #include <iostream>

2 using namespace std;


3 struct str {
4 int t[3];
5 char s[3];
6 };
7
8 int main() {
9 str a = { 1, 2, 3, 'a', 'b', 'c' };
10 str b = { 5, 6, 7, 'x', 'y', 'z' };
11 cout << char(b.s[0] + a.t[0]) << int(a.s[2] - a.s[0]) << int(b.s[2] - b.s[1]);
12 return 0;
13 }
14 //
15 #include <iostream>
16 using namespace std;
17 int main() {
18 int a = 1, b = 2;
19 int c = a << b;
20 int d = 1 << c;
21 int e = d >> d;
22 cout << e;
23 return 0;
24 }
25 //
26 #include <iostream>
27 using namespace std;
28 int main() {
29 int a = 2;
30 switch(a << a) {
31 case 8 : a++;
32 case 4 : a++;
33 case 2 : break;
34 case 1 : a--;
35 }
36 cout << a;
37 return 0;
38 }
39 //
40 #include <iostream>
41 using namespace std;
42 int main() {
43 int i = 3, j = 0;
44 do {
45 i--;
46 j++;
47 } while(i >= 0);
48 cout << j;
49 return 0;
50 }
51 //
52 #include <iostream>
53 using namespace std;
54 struct str {
55 int t[3];
56 char s[3];
57 };
58 //
59 int main() {
60 str z[3];
61 for(int i = 0; i < 3; i++)
62 for(int j = 0; j < 3; j++) {
63 z[i].s[j] = '0' + i + j;
64 z[j].t[i] = i + j;
65 }
66 cout << z[0].s[1] << z[1].t[2] << z[2].s[0];
67 return 0;
68 }
69 //
70 #include <iostream>
71 using namespace std;
72 int main() {
73 char arr[5] = { 'a', 'b', 'c', 'd', 'e' };
74 for(int i = 1; i < 5; i++) {
75 cout << "*";
76 if((arr[i] - arr[i - 1]) % 2)
77 continue;
78 cout << "*";
79 }
80 return 0;
81 }
82
83
84 #include <iostream>
85 using namespace std;
86 int main() {
87 bool t[5];
88 for(int i = 0; i < 5; i++)
89 t[4 - i] = !(i % 2);
90 cout << t[0] && t[2];
91 return 0;
92 }
93
94 #include <iostream>
95 using namespace std;
96 int main() {
97 int a = 1, b = 2;
98 int c = a | b;
99 int d = c & a;
100 int e = d ^ 0;
101 cout << e << d << c;
102 return 0;
103 }
104
105 #include <iostream>
106 using namespace std;
107 int main() {
108 for(float val = -10.0; val < 100.0; val = -val * 2) {
109 if(val < 0 && -val >= 40)
110 break;
111 cout << "*";
112 }
113 return 0;
114 }
115 #include <iostream>
116 struct sct {
117 int t[2];
118 };
119
120 struct str {
121 sct t[2];
122 };
123
124 int main() {
125 str t[2] = { {0, 2, 4, 6}, {1, 3, 5, 7} };
126 cout << t[1].t[0].t[1] << t[0].t[1].t[0];
127 return 0;
128 }
129
130
131 int i = 1, j = i++, k = --i;
132 if(i > 0) {
133 j++;
134 k++;
135 }
136 else {
137 k++;
138 i++;
139 }
140 if(k == 0) {
141 i++;
142 j++;
143 }
144 else {
145 if(k > 0)
146 k--;
147 else
148 k++;
149 i++;
150 }
151 cout << i * j * k;
152
153
154 double big = 1e15;
155 double small = 1e-15;
156
157 cout << fixed << big + small;
158
159
160 #include <iostream>
161 using namespace std;
162 int main() {
163 float val = 100.0;
164 do {
165 val = val / 5;
166 cout << "*";
167 } while(val > 1.0);
168 return 0;
169 }
170
171 int i = 0, j = i++, k = --i;
172 if(i > 0)
173 j++;
174 else
175 k++;
176 if(k == 0)
177 i++;
178 else if(k > 0)
179 k--;
180 else
181 k++;
182 cout << i * j * k;
183
184 #include <iostream>
185 using namespace std;
186 int main() {
187 int g[3][3] = {{2, 4, 8}, {3, 6, 9}, {5, 10, 15}};
188 for(int i = 2; i >= 0; i--)
189 for(int j = 0; j < 3; j++)
190 g[i][j] += g[j][i];
191 cout << g[1][1];
192 return 0;
193 }
194
195 #include <iostream>
196 using namespace std;
197 int main() {
198 for(float val = -10.0; val < 100.0; val = -val * 2)
199 cout << "*";
200 return 0;
201 }
202
203 #include <iostream>
204 using namespace std;
205 int main() {
206 int t[] = { 8, 4, 3, 2, 1 }, i;
207 for(i = t[4]; i < t[0]; i++)
208 t[i - 1] = -t[3];
209 cout << i;
210 return 0;
211 }
212
213 #include <iostream>
214 using namespace std;
215 int main() {
216 int i = 5, j = 0;
217 while(i > 0) {
218 i--;
219 j++;
220 }
221 cout << j;
222 return 0;
223 }
224
225 #include <iostream>
226 using namespace std;
227 int main() {
228 int a[] = {4, 0, 3, 1, 2};
229 int b[] = {1, 2, 3, 4, 5};
230
231 for(int i = 0; i < 5; i++)
232 b[a[i]] = b[4 - i];
233 cout << b[0] << b[4];
234 return 0;
235 }
236
237 bool yes = !false;
238 bool no = !yes;
239 if(!no)
240 cout << “true”;
241 else
242 cout << “false” ;
243
244

You might also like