fork download
  1. //Q95. Check if one string is a rotation of another.
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. int main() {
  6. char str1[100], str2[100], temp[200];
  7. gets(str1);
  8. gets(str2);
  9.  
  10. if(strlen(str1) != strlen(str2)) {
  11. printf("Not Rotation");
  12. return 0;
  13. }
  14.  
  15. strcpy(temp, str1);
  16. strcat(temp, str1);
  17.  
  18. if(strstr(temp, str2))
  19. printf("Rotation");
  20. else
  21. printf("Not Rotation");
  22. }
  23.  
Success #stdin #stdout 0s 5316KB
stdin
abcde
deabc
stdout
Rotation