تکه کد زیر را در نظر بگیرید:
#include <iostream> #include <cstring> #include <string> using namespace std; int main() { char c, s[10]; int x, *p; long long m; /* code here! */ return 0; }
قرار است هر کدام از شبهکدهای زیر را در قسمت مشخص شده (/ * code here! * /) قرار داده و تا جای ممکن به جواب برسیم. بهطور دقیقتر، برای هر یک از کدهایی زیر
c = 1000 / float(10) - 35; cout << c << endl;
x = (1 << 32) - 1; cout << x << endl;
strcpy(s, "hello0\n"); s[1] = 'A' / 1LL + 0X00; p = (int *)(s + 1); if (*p == 'A') cout << c << endl;
char c2 = -1; c2++; if (c2 == 0) cout << "Yes!" << endl;
strcpy(s, "welcome"); x = s[strlen(s)]; x++; x++; p = &x; if (x & (*p == 2)) cout << "Bah Bah!" << endl;
x = 0; strcpy(s,"1234567890"); for (c = s[8]; c != 0; c++) x += c; cout << x << endl; for (c = s[8]; c != '0'; c++) x += c; cout << x << endl;
int &q = x; x = 5; *p = q; x++; x = *(&q); cout << x << " " << p << " " << &q << endl;
x = 1; do { c = -2; for ( ; ; x++,c++) if (x == 10) break; else continue; } while (c < -1); cout << "akheysh! " << x << endl;