Talk:C: Difference between revisions
Content added Content deleted
(Created page with "<nowiki> #include <stddef.h> #include <ctype.h> #include <stdlib.h> #include <stdio.h> #define K62 62 extern int main(int ac, const char *const *av) { char a[666]; for (; fgets(a, stdin); ) { size_t y, z= strlen(a); char *s= a+z; for (; z && (--z, iscntrl(*--s)) ;) { *s= 0; } y= z? (z-1)/K62+1: 1; z= z<=3? z: 3; } } </nowiki>") |
(more) |
||
Line 7: | Line 7: | ||
#define K62 62 |
#define K62 62 |
||
#define K77 77 |
|||
#define K3 4 |
|||
#define K3_ (K3-1) |
|||
extern int main(int ac, const char *const *av) { |
extern int main(int ac, const char *const *av) { |
||
static char b[K62][K77][K3]; |
|||
char a[666]; |
char a[666]; |
||
⚫ | |||
for (; fgets(a, stdin); ) { |
for (; fgets(a, stdin); ) { |
||
size_t y, z= strlen(a); |
size_t y, z= strlen(a); |
||
char *s= a+z; |
char *s= a+z; |
||
for (; z && (--z, iscntrl(*--s)) |
for (; z && (--z, iscntrl(*--s)); *s= 0); |
||
⚫ | |||
⚫ | |||
y= z? (z-1)/ |
y= z? (z-1)/K77+1: 1; |
||
z= z |
z= z>=K3_? K3_ : z; /* !needed? */ |
||
for (++y; --y; ++ln, z= 0) { |
|||
int lo= ln%K62, hi= ln/62; |
|||
sprintf(b[lo][hi], "%-" K3 ".*s", z, a); |
|||
⚫ | |||
} |
} |
||
for (ln= 0-1; ++ln<K62; ) puts(*b[ln]); |
|||
} |
} |
||
</nowiki> |
</nowiki> |
Revision as of 15:20, 10 September 2022
#include <stddef.h> #include <ctype.h> #include <stdlib.h> #include <stdio.h> #define K62 62 #define K77 77 #define K3 4 #define K3_ (K3-1) extern int main(int ac, const char *const *av) { static char b[K62][K77][K3]; char a[666]; int ln= 0; for (; fgets(a, stdin); ) { size_t y, z= strlen(a); char *s= a+z; for (; z && (--z, iscntrl(*--s)); *s= 0); y= z? (z-1)/K77+1: 1; z= z>=K3_? K3_ : z; /* !needed? */ for (++y; --y; ++ln, z= 0) { int lo= ln%K62, hi= ln/62; sprintf(b[lo][hi], "%-" K3 ".*s", z, a); } } for (ln= 0-1; ++ln<K62; ) puts(*b[ln]); }