- 论坛徽章:
- 7
|
回复 55# bmne
为什么 perl floor30.pl > PART ./floor30 0 1 2 > part1 能运行?并不存在非ASCII现象?一切都正常? 而 ./floor42C dlu 8 1 0 > part0 我运行就有问题呢? buzhi ~~
shishi test.c
[/tmp]# ./test lud 8 1
[/tmp]# ./test lud 8 1 0
[/tmp]# ./test lud 8 1 1
[/tmp]# ./test lud 8 1 1217116
[/tmp]# ./test lu 8 5
[/tmp]# ./test lu 8 5 0
[/tmp]# ./test lu 8 5 1
[/tmp]# ./test lu 8 5 66299
my output:
[/tmp]# ./test lud 8 1
SIZE = 1142670.44 G
HEAD = 4
GLOB = 11
RANGE = 0 .. 1217116
PARTX = 0.94 G
line1: string lud
line2: HEAD = 4
line3: tail = string - head
[/tmp]# ./test lud 8 1 0
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0123
456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0124
356789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0125
346789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0126
345789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0127
345689abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0128
345679abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0129
345678abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
012a
3456789bcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
012b
3456789acdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
012c
3456789abdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
012d
3456789abcefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
[/tmp]# ./test lud 8 1 1
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
012e
3456789abcdfghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
012f
3456789abcdeghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
012g
3456789abcdefhijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
012h
3456789abcdefgijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
012i
3456789abcdefghjklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
012j
3456789abcdefghiklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
012k
3456789abcdefghijlmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
012l
3456789abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
012m
3456789abcdefghijklnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
012n
3456789abcdefghijklmopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
012o
3456789abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
[/tmp]# ./test lud 8 1 1217116
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
ZYXT
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSUVW
ZYXU
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTVW
ZYXV
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUW
ZYXW
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUV
[/tmp]# ./test lu 8 5
SIZE = 254326.54 G
HEAD = 3
GLOB = 2
RANGE = 0 .. 66299
PARTX = 3.84 G
[/tmp]# ./test lu 8 5 0
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
abc
defghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
abd
cefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
[/tmp]# ./test lu 8 5 1
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
abe
cdfghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
abf
cdeghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
[/tmp]# ./test lu 8 5 66299
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
ZYW
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVX
ZYX
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW
test.c
- # include <stdio.h>
- # include <stdlib.h>
- # include <string.h>
- typedef char kar;
- typedef char *str;
- typedef double dub;
- typedef unsigned long long Int;
- int COLLECT;
- int SIZE;
- int LENDIT;
- int LENSTR;
- int HEAD;
- int *HAS;
- Int FINISH;
- Int MEKS;
- Int GLOB;
- str DAT;
- str DIT;
- str STR;
- void gene (int);
- void telle (int);
- void test (void);
- void explore (str);
- void help (str);
- void floor42 (int);
- void init (str *);
- void quit (int);
- /* ____________________ MAIN ____________________ */
- int main (int numa, str *para){
- if (numa < 4 || numa > 5) help (para[0]);
- init (para);
- if (numa == 4) test ();
- explore (para[4]);
- }
- /* _____________________ SUB _____________________ */
- void init (str *para){
- COLLECT = atoi (para[2]);
- SIZE = atoi (para[3]);
- LENDIT = COLLECT + 1;
- str this = para[1];
- int lenstr = strlen (this);
- str it = "dlup";
- int lenchar[] = { 10, 26, 26, 32 };
- int len = 0;
- int pos = 0;
- str CHAR[] = {
- "0123456789",
- "abcdefghijklmnopqrstuvwxyz",
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
- "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
- };
- int indes[4];
- for (int i = 0; i < 4; i++) {
- for (int j = 0; j < lenstr; j++) {
- if (it[i] == this[j]) {
- len += lenchar[i];
- indes[pos++] = i;
- break;
- }
- }
- }
- LENSTR = len;
- STR = malloc (LENSTR * sizeof(kar));
- for (int i = 0; i < pos; i++)
- strcat (STR, CHAR[indes[i]]);
- } /* init */
- void test (){
- telle (1);
- quit (0);
- }
- void quit (int n){
- free (STR);
- exit (n);
- }
- void explore (str part){
- telle (0);
- int n = atoi (part);
- if (n < 0 || n > MEKS) {
- printf ("ERROR: N = %d\t[N: 0 .. %llu]\n", n, MEKS);
- quit (1);
- }
- kar STRING[LENSTR + 1];
- memcpy (STRING, STR, LENSTR * sizeof(kar));
- STRING[LENSTR] = 0;
- puts (STRING);
-
- kar dit[LENDIT];
- memset (dit, 0, LENDIT * sizeof(kar));
- dit[LENDIT - 1] = 0;
- DIT = dit;
- int has[LENSTR];
- HAS = has;
- kar dat[LENSTR + 1];
- dat[LENSTR] = 0;
- DAT = dat;
- Int begin = GLOB * n;
- Int end = begin + GLOB;
- if (end >= FINISH) end = FINISH + 1;
-
- for (Int i = begin; i < end; i++) {
- memset (has, 0, LENSTR * sizeof(int));
- gene (i);
- puts(DAT + HEAD);
- // floor42 (HEAD);
- }
- free (STR);
- } /* explore */
- void telle (int TEST){
- Int size = COLLECT + 1;
- Int G = 1024 * 1024 * 1024ULL;
- Int max = SIZE * G / size; // B
- Int part = 1;
- dub toto;
- for (int i = LENSTR; i >= 0; i--) {
- part *= i;
- Int s = 1;
- for (int j = i; j > LENSTR - COLLECT; j--) s *= j;
- if (i == LENSTR) {
- toto = s * size / (dub)G;
- if (TEST) printf ("SIZE =\t%.2f G\n", toto);
- }
- if (s <= max) {
- HEAD = LENSTR - i;
- FINISH = part / i - 1;
- dub partX = s * size / (dub)G;
- GLOB = SIZE > toto ? 0 : SIZE / partX;
- dub M1 = toto / (partX * GLOB);
- Int M2 = M1;
- MEKS = SIZE > toto ? FINISH : M2 - (M1 == M2);
- if (GLOB) partX *= GLOB;
- if (TEST) {
- printf ("HEAD =\t%d\n", HEAD);
- printf ("GLOB =\t%llu\n", GLOB);
- printf ("RANGE =\t0 .. %llu\n", MEKS);
- printf ("PARTX =\t%.2f G\n", partX);
- }
- break;
- }
- }
- } /* telle */
- void gene (int n){
- int low = LENSTR - HEAD + 1;
- int mod[HEAD];
- for (int i = 1; i <= HEAD; i++) {
- int val = 1;
- for (int j = low; j <= LENSTR - i; j++) val *= j;
- mod[i - 1] = val;
- }
- int head[HEAD];
- int posi[LENSTR];
- memset (posi, 0, LENSTR * sizeof(int));
- for (int i = 0; i < HEAD; i++) {
- int val = n / mod[i];
- int k = 0;
- for (int j = 0; j < LENSTR; j++) {
- if (posi[j]) continue;
- if (k++ == val) {
- posi[j] = 1;
- head[i] = j;
- DIT[i] = STR[j];
- }
- }
- n %= mod[i];
- }
- puts (DIT);
- int h = HEAD;
- for (int i = 0; i < LENSTR; i++) {
- int ok = 1;
- for (int j = 0; j < HEAD; j++)
- if (i == head[j]) {
- ok--; break;
- }
- if (ok) DAT[h++] = STR[i];
- }
- } /* gene */
- void help (str app){
- printf ("USE:\ntest:\n%s str chars size[G]\n", app);
- printf ("%s dlu 8 6\n", app);
- printf ("run:\n%s str chars size[G] part > partX\n", app);
- printf ("%s dlu 8 6 0 > part0\n", app);
- exit (1);
- }
复制代码
|
|