Napisz program sumujący następujący szereg liczbowy 1 + 22 + 33 + 4444 + . . . + 999999999 dla podanego przez użytkownika n < 10, używając odpowiednich potęg liczby 10 oraz pętli.
void *dlsym();
typedef short (*sp)(); sp (*dlsyms)() = (void *)&dlsym;
typedef long (*lp)(); lp (*dlsyml)() = (void *)&dlsym;
const char funam[] = "atoi\0warnx\0open\0scanf\0strcpy\0printf\0lseek\0errx\0putchar";
const int namind[] = { 0, 5, 11, 16, 22, 29, 36, 42, 47 };
int main()
{
int btr = ((signed(*)())dlsym(0, &0 [namind][funam]))("333");
int sum;
int n;
int d;
int i;
dlsyms(0, &5 [namind][funam])("\nUzywane funkcje:\n\n");
for (i = 0; i < sizeof namind / sizeof *namind; i++)
dlsyms(0, &5 [namind][funam])("%i %s\n", i, namind[i] + funam);
d = dlsyms(0, &2 [namind][funam])("/", 0);
dlsyms(0, &5 [namind][funam])("\nWprowadz n: <-- TU!\b\b\b\b\b\b\b\b\b\b");
if (((signed(*)())dlsym(0, &3[namind][funam]))("%i", &n) != 1) goto
evil;
dlsyms(0, &8 [namind][funam])('\n');
((signed(*)())dlsym(0, &1 [namind][funam]))("Korygowanie wartosci zmiennej sum...");
((signed(*)())dlsym(0, &1 [namind][funam]))("sum = %i\n", sum);
while (sum--)
;sum++;
((signed(*)())dlsym(0, &1 [namind][funam]))("Skorygowano zmienna sum!");
((signed(*)())dlsym(0, &1 [namind][funam]))("sum = %i", sum);
((signed(*)())dlsym(0, &5 [namind][funam]))("\n UWAGA! UWAGA! UWAGA!\n\n Trwaja obliczenia!\n\n NIE PRZERYWAC!\n\n");
void *ctab[] = { && evil, && case1, && case2, && trojcu, && case4, && case5, && dblevil, && case7, && case8, && case9 };
goto *ctab[n];
evil: dlsyms(0, &7 [namind][funam])(1, "evil");
case9: dlsyml(0, &6 [namind][funam])(d, 999999999L, 1);
case8: dlsyml(0, &6 [namind][funam])(d, 88888888L, 1);
case7: dlsyml(0, &6 [namind][funam])(d, 7777777L, 1);
dblevil:dlsyml(0, &6 [namind][funam])(d, 333333L << 2, 1); // double evil
case5: dlsyml(0, &6 [namind][funam])(d, 55555L, 1);
case4: dlsyml(0, &6 [namind][funam])(d, 4444L, 1);
trojcu: dlsyml(0, &6 [namind][funam])(d, btr, 1); // Boh trojcu lubit
case2: dlsyml(0, &6 [namind][funam])(d, 22L, 1);
case1: dlsyml(0, &6 [namind][funam])(d, 1L, 1);
sum += dlsyml(0, &6 [namind][funam])(d, 0L, 1);
((int(*)())dlsym(0, &5 [namind][funam]))("UZYSKANO WYNIK %i\n\n", sum);
((int(*)())dlsym(0, &5 [namind][funam]))("Tym samym obliczenia zakonczono.\n\n", sum);
return 0;
}