C, 374
โดยย้ายหน่วยความจำ
ไม่ใช่สั้นที่สุด แต่จะเร็วขึ้นหรือไม่
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *s;
void m (int d, int f, int p)
{
memmove (s+p+f, s+p, strlen(s)-p+1); // Shift a part of the string to make room for our insertion
memcpy (s+p, s+d, f); // Copy the desired reference in place
}
int main ()
{
s = malloc (168);
strcpy (s,"I'm Slim Shady. Yes, the real.\nAll you others are just imitating.\nSo, won't the please stand up?\nP. ");
m (0, 4, 21);
m (8, 6, 33);
m (3, 11, 54);
m (28, 5, 100);
m (3, 11, 105);
m (118, 14, 135);
m (134, 16, 151);
puts (s);
}
มันยาว 374 ตัวอักษรหลังจากการลดขนาด
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char*s;void m(int d,int f,int p){memmove(s+p+f,s+p,strlen(s)-p+1);memcpy(s+p,s+d,f);}int main(){s=malloc(168);strcpy(s,"I'm Slim Shady. Yes, the real.\nAll you others are just imitating.\nSo, won't the please stand up?\nP. ");m(0,4,21);m(8,6,33);m(3,11,54);m(28,5,100);m(3,11,105);m(118,14,135);m(134,16,151);puts(s);}