#include #include #include #include #include using namespace std; #define N 1000000 #define MIN_LEN 20 #define MAX_LEN 50 #define MAX_CHAR 'd' int main(void) { srand(time(NULL)); string s[N]; char buf[MAX_LEN + 1]; // Generate some strings for (int i = 0; i < N; i++) { int len = rand() % (MAX_LEN - MIN_LEN + 1) + MIN_LEN; for (int j = 0; j < len; j++) { buf[j] = rand() % (MAX_CHAR - 'a' + 1) + 'a'; } buf[len] = '\0'; s[i] = buf; } sort(s, s + N); // Print them // for (int i = 0; i < N; i++) { // cout << s[i].length() << "[" << s[i] << "]\n"; // } }