Anonymous user
Largest int from concatenated ints: Difference between revisions
→{{header|C}}: replaced with simpler code with total length limitation
(Promoted to task from draft.) |
(→{{header|C}}: replaced with simpler code with total length limitation) |
||
Line 19:
<lang C>#include <stdio.h>
#include <stdlib.h>
#include <
{
char ab[32], ba[32];
sprintf(ab, "%d%d", *(int*)a, *(int*)b);
sprintf(ba, "%d%d", *(int*)b, *(int*)a);
return len;▼
return strcmp(ba, ab);
}
▲int icsort(const void *px, const void *py)
{
int i;
printf("%d", a[i]);
putchar('\n');
}
int main(void)▼
▲long maxcat(int sz, ...)
{
int x[] = {1,
int y[] = {54, 546, 548, 60};
maxcat(x, sizeof(x)/sizeof(x[0]));
maxcat(y, sizeof(y)/sizeof(y[0]));
▲ qsort(ns, sz, sizeof(int), icsort);
▲ for (i = 0; i < sz; ++i)
▲int main(void)
}</lang>
{{out}}
<pre>998764543431
6054854654</pre>
|