C, 374
Hafızayı taşıyarak
En kısa değil ama daha hızlı olabilir mi?
#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);
}
Minyatürden uzun süre 374 karakter.
#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);}