char a[] = "aa";
char b[] = "bb";
char c[] = "cc";
char d[] = "dd";
char e[] = "ee";
char f[] = "ff";
int main()
{
int n, nn, x;
int bits = 6;
char** vars = (char**) malloc(bits * sizeof(char*));
vars[0] = a;
vars[1] = b;
vars[2] = c;
vars[3] = d;
vars[4] = e;
vars[5] = f;
for (n = 0; n != (2 << bits); ++n) {
x = n;
for (nn = 0; nn != bits; ++nn) {
if (x % 2)
printf("%s", vars[nn]);
x >>= 1;
}
printf("\n");
}
return 0;
}
#include <iostream>
#include <ncurses.h>
using namespace std;
string get_string()
{
string result;
while(true) {
int c = getch();
if (c == -1)
continue;
if (c == 10)
break;
if (c == 127) {
if (result.length() > 0) {
result = result.substr(0, result.length() - 1);
clear();
addstr("Enter name: ");
addstr(result.c_str());
}
}
else if (c > 33 && c < 127) {
result += (char) c;
addch(c);
}
}
return result;
}
int main() {
initscr();
noecho();
addstr("Enter name: ");
string name = get_string();
endwin();
cout << endl << name << endl;
return 0;
}
unsigned int calc_hash(const unsigned char* s, unsigned int len)
{
char ch = 0;
unsigned int result = 0;
unsigned int n = 0;
for ( ; n != len; ++n) {
result ^= (s[n] - ch) << (n % 3) * 8;
ch = s[n];
if (result & 0x800000) {
result <<= 1;
result |= 1;
}
else
result <<= 1;
}
result &= 0xFFFFFF;
result |= (n % 256) << 24;
return result;
}
myprog1 | myprog2