J'essaye this problème de spoj. Mais je ne pourrais pas obtenir pourquoi il donne la faute de segmentation dans quelque cas de test.Pourquoi une erreur de segmentation?
#include <iostream>
#include <cstring>
#include <stdio.h>
using namespace std;
int getMin(char *txt,int n) {
int min = 0;
for(int i = 0 ; i < n ; i++) {
if(strcmp(txt+min ,txt+i) > 0)
min = i;
}
return min;
}
int main() {
char *s = new char[200005];
scanf("%s",s);
int n = strlen(s);
strcat(s+n,s);
printf("\n%d",getMin(s,n));
delete[] s;
return 0;
}