Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Two.c. Must be in C! The code is given below all I need is the function sameWhenShifted. #include #include int sameWhenShifted(char *, char *); int
Two.c. Must be in C! The code is given below all I need is the function sameWhenShifted.
#include
int sameWhenShifted(char *, char *);
int main(int argc, char *argv[]) { char s1[100], s2[100]; printf("Enter string 1 : "); scanf("%s", s1); printf("Enter string 2 : "); scanf("%s", s2); int ans = sameWhenShifted(s1, s2); if ( ans != -1 ) printf("%s shifts %d to get %s ", s1, ans, s2); else printf("Cannot build %s from %s ", s2, s1); return 0; }
As an example, consider the three fles shown at the right, each having ten data values56 in them. The program is run as shown, generating the output shown in red. To make this example clearer to visualize, the values that differ on each line are shown in red. 68 6 69 68 70 65 68 ./a.out 10 Datal Data2 Data3 Datal has 2 possible bad values Data2 has 1 possible bad values Data3 has 2 possible bad values There are 1 unknown cases 2. Name this program two.c-This This program reads two strings from standard input and determines whether or not the second string can be created from the first string by shifting the characters to the left by N positions (and moving the character at beginning of the string to the end). For example, the string CDEAB can be created from ABCDE by shifting the all the characters to the left by 2 positions. If it is possible to build the second string by shifting the first string to the left by N positions, return N. Note that you can build the string ABC by shifung ABC zero locations, so return zero if the two strings are identical. If it is not possible to build the second string by shifting the first string, return -1. #includeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started