1.separate 1.txt content into three files (amount, ID card, code ).
2. to ensure fairness in the game, write the code as a line (for some language features, directly calculate the size of the code file)
3. The minimum number of codes indicates the winner (space calculation ).
1. txt
1234567890 | 312 | 32145
1234567890 | 312 | 32145
1234567890 | 312 | 32145
1234567890 | 312 | 32145
1234567890 | 312 | 32145
1234567890 | 312 | 32145
1234567890 | 312 | 32145
1234567890 | 312 | 32145
1234567890 output to ID card .txt
312 output to amount .txt
21145 output to generation number .txt
Below is the view plaincopy to clipboardprint I wrote in c?
# Include <stdio. h>
# Include <windows. h>
FILE * G;
Char * wN [6] = {"ID card:", "amount:", "Code:", "ID card .txt", "amount .txt", "Number .txt "};
Main (int argc, char * argv []) {
If (argc = 2 ){
Char T [256];
Char w [64];
FILE * f;
Char * p;
Int I;
F = fopen (argv [1], "r ");
While (fgets (T, 80, f )){
I = 0;
P = strtok (T, "| ");
While (p! = 0 ){
Sprintf (w, "% s", wN [I], p, I <2? "": ""); // Line feed needs to be processed
G = fopen (wN [I + 3], "a + ");
Fwrite (w, strlen (w), 1, G );
Fclose (G );
P = strtok (0, "| ");
I ++;
}
}
}
}
# Include <stdio. h>
# Include <windows. h>
FILE * G;
Char * wN [6] = {"ID card:", "amount:", "Code:", "ID card .txt", "amount .txt", "Number .txt "};
Main (int argc, char * argv []) {
If (argc = 2 ){
Char T [256];
Char w [64];
FILE * f;
Char * p;
Int I;
F = fopen (argv [1], "r ");
While (fgets (T, 80, f )){
I = 0;
P = strtok (T, "| ");
While (p! = 0 ){
Sprintf (w, "% s", wN [I], p, I <2? "": ""); // Line feed needs to be processed
G = fopen (wN [I + 3], "a + ");
Fwrite (w, strlen (w), 1, G );
Fclose (G );
P = strtok (0, "| ");
I ++;
}
}
}
}
--------------------------
I think the script code is short. My colleagues only write 256 bytes of code using python. I actually have 500 + bytes.